C
Csaba Gabor
How can I most reliably detect when a link has been clicked to open in
a new tab or to open in a new window? I have not found this question
well adressed in the pages returned up my searches.
I am doing some statistics gathering. In particular, I have some
links that point to external websites (they are product links) and I
would like to know when they are clicked, to verify against what the
destination site reports. If they are clicked "normally", to open in
the same window, it is no problem because one just adds an onclick
handler to the link. All my onclick handler does is to send a request
out via an embedded Iframe (so it can be logged by the server), and
this request gets sent before the new page starts to load.
However, the onclick does not fire when the link is opened in a new
window or new tab (and that's how I always click my links because I
don't want to lose the previous page). It is insufficient to detect
oncontextmenu because the user might not activate the link (and I'd
rather not have false positives). I don't need a bulletproof solution
- I will be quite happy if the detection mechanisms works a good
percentage of the time in recent versions of IE and FF.
Regards,
Csaba Gabor from Vienna
a new tab or to open in a new window? I have not found this question
well adressed in the pages returned up my searches.
I am doing some statistics gathering. In particular, I have some
links that point to external websites (they are product links) and I
would like to know when they are clicked, to verify against what the
destination site reports. If they are clicked "normally", to open in
the same window, it is no problem because one just adds an onclick
handler to the link. All my onclick handler does is to send a request
out via an embedded Iframe (so it can be logged by the server), and
this request gets sent before the new page starts to load.
However, the onclick does not fire when the link is opened in a new
window or new tab (and that's how I always click my links because I
don't want to lose the previous page). It is insufficient to detect
oncontextmenu because the user might not activate the link (and I'd
rather not have false positives). I don't need a bulletproof solution
- I will be quite happy if the detection mechanisms works a good
percentage of the time in recent versions of IE and FF.
Regards,
Csaba Gabor from Vienna