Thursday, 5 December 2013

Make an anchor tag with href but do not let user navigate away

This can be utilized a lot for SEO purposes. Anchor tag href would be crawled by search engines, but when user will be click, it will not navigate away the user from the page, and you can handle the onclick even in anyway you want to.

<a href="" onclick="dothis(event); return false;">Click me</a>

function dothis(e){
if (!e) var e = window.event;
if (e.stopPropagation)
return false;