Reply to Re: Link in Title Attribute

Your name:

Reply:


Posted by Jonathan N. Little on 09/28/07 20:43

Blinky the Shark wrote:
> I'd say this was a weird one. Someone in a not-HTML group (a browser
> group it was) this morning asked for a way to have the user that clicks
> on a link be sent to a URL in the anchor's title attribute rather than
> to the hreffed URL.
>
> Anyone ever heard of such?
>
> Yes, I have the thread set for "watch". I just thought it might be an
> interesting thing to look at here.
>
>

It would be nasty eh? Well seems to work...I would say the JavaScript
would go in external file to complete the deception. The link will of th
thatway.html and not thisway.html, of course when JavaScript is enabled:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta http-equiv="content-language" content="en-us">
<title>Deception</title>

<script type="text/javascript">

function trick(e){
var me;
if(!e) var e=window.event;
if(e.target) me=e.target; // W3C
else if(e.srcElement) me=e.srcElement; // MSIE
if(me.nodeType == 3) me=me.parentNode; // Safari bug els with TEXT

me.href=me.title; // now do the switcheroo!
}

function initTrick(){
var dalink=document.getElementById('fakeout');

if(dalink.addEventListener){
dalink.addEventListener('click', trick, false);
}
else if(dalink.attachEvent){ //MS IE support
dalink.attachEvent('onclick', trick);
}
}

// attach event after page loads
if( window.addEventListener ) {
window.addEventListener('load',initTrick,false); //legacy
} else if( document.addEventListener ) {
document.addEventListener('load',initTrick,false); //proper
} else if( window.attachEvent ) {
window.attachEvent("onload", initTrick); //IE only
}

</script>

</head>
<body>
<p>Well, let's see here...
<a id="fakeout" href="thisway.html" title="thatway.html">Fake This Way</a>
</p>
</body>
</html>



--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация