Capture link clickthrough events from Javascript?

If you're looking at ways to see outbound link hits, you could try the following.

If you're looking at ways to see outbound link hits, you could try the following: Use a script, example link. Php? Src=example.com that increments a counter per IP & User Agent combo when clicked.

This however doesn't look very good in the status bar. It could also be saved by web crawlers. Use unobtrusive JavaScript to attach event handlers on links that are external.

You could determine if they are external if the hostname is present and doesn't match the one you are on. You could then use this event handler to save the href, prevent default of click event, to increment a number much like the first script and then send the window. Location to the actual href.

This of course fails without JavaScript enabled/supported.

1, These are the two ways most commonly used. – Paolo Bergantino Mar 18 '09 at 0:42 Thanks Paolo... I recommend these options from the comments on the OP. – alex Mar 18 '09 at 0:44.

There are many ways that a user can create a new tab in a browser: Middle click Context menu Mouse gesture "New tab" button on the toolbar "File" > "New tab" Unfortunately there is no way to handle all these and potentially more user actions that could create a new tab.

Thank you for your answer. I'm only interested in new-tab events originating from a link on my site, so most of these do not apply. Any way to achieve that?

– Silver Dragon Mar 18 '09 at 0:19 Well that does change things a bit - I think where you might have some trouble is with mouse-gestures and folks with multi-button mice. Remember that folks may have many different ways to open a link in a new tab. Good luck :) – Andrew Hare Mar 18 '09 at 0:22.

Middle click capturing does work. You have to check the browsers version (ie6 doesn't open anything on middle click), have to use mousedown and mouseup to check if these two events happen on the same element, have to check which button was pressed. (jQuery "which" function, for example) If mousedown and mouseup happen on the same element, a new window opens, so you'll know that your link was clicked.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions