Being a bit of a neophyte (well, maybe I'm a journeyman now) to javascript, I have been tracking the links that users click on in my AJAX homepage site by having the URL for the link be something like http://www.memeflow.com/goto/goto.php?hit=234, which after noting the hit would redirect to the requested page. Rather cryptic and problematic.

The problem is that this url is what shows up in the status bar, not the url for the site that the user is expecting to navigate to. The other problem is that you can't right-click on it to copy the url to the clipboard.

So, along comes various threads on message boards about google tracking clicks by rewriting the url on the 'onmousedown' event. Very sneaky and very clever.

I've told users that I'm tracking the clicks since day one, so this isn't a problem for me. So now, the url for each link is exactly the correct link for the site the user is expecting to visit, but the element has this attached to it for the 'onmousedown' event.

this.nodeItem.onmousedown = function(evnt)

{

var left = true;

if ((evnt) && evnt.which)

{

if (evnt.which != 1)

left = false;

}

else if (event && event.button)

{

if (event.button != 1)

left = false;

}

if (left)

this.setAttribute('href', 'goto.php?hit=' + id);

}

Most of that code is actually checking to make sure the click was from the left button, so that a right mouse-click has the desired behaviour.

I hope someone finds this useful...