We can’t take the credit for developing this javascript technique ourselves, but we’ll take the credit (thank you very much!) for passing on to you one of the handiest javascript linking tricks we’ve seen in awhile. Using it, you can code an XHTML link to point to one URL, while passing clicks on the link through to a different URL. We’ll leave it to your imagination to figure out some of the different uses this might be put to, but two obvious ones are:
- Ensuring that Page Rank isn’t lost on an obscure page deeply buried somewhere in a site, and
- Tracking clicks through a link without cluttering it up with tracking parameters.
This simple but clever javascript linking trick is as follows:
<a href="http://www.example.com/" title="Real link points to example.com, while click on the link points to example.com/real-landing-page.html" onmouseover="if(this.href.indexOf('?')==-1) this.href+='real-landing-page.html"'; window.status='http://www.example.com/'; return true" onmouseout="window.status='Done'; return true">Link to Example.com</a>
Here, the real link is coded to point to example.com, but the javascript attached to the onmouseover event ensures that any subsequent click on the link will have a different landing page appended to the destination. Obviously, this trick won’t modify the click destination if javascript is disabled — and it won’t work if someone selects and goes to the link without a mouseover (e.g., via keyboard navigation). But for the overwhelming majority of users, this trick will ensure that the link can point one place, while the clicks go to another.
If anyone has any extra-creative uses for this little gem apart from the obvious ones described above, we’d love to hear about them!

Bookmark and Share: