Catching click event on link

Advert test
#1
I'm looking to try and catch a click on a link to update a database table to keep track of what links a url clicks on, its only certain links on a page so it doesn't have to catch every link on the site.

I was looking at using jQuery or AJAX to do this but then theres the inherant problem that if someone disabled Javascript then it wouldn't work, my question is, is this worry justified of does the use of Javascript for this function out way not using Javascript.

Also with jQuery if I was to use an onclick function will this stop the normal behaviour of the link from working like going to the page specified in the href attribute?
 
#2
Hi,

If you do use jQuery, you can return true in your onClick function after you've handled what you need to to allow the default action to proceed.

Code:
function myClickFunction()
{

    // Handle what you need to here, then return true

    return true;

}
But if you want a failsafe option in case of no javscript support, you would track the click within the url that the link points to....e.g - the php script that updates the database.
 
Top