OtisUsenet said on 22/03/2006 10:37 AM AEST:
Hello,
I have some onClick events in <a href...> elements, so they get called
when a user clicks on a link.
This works well, and looks like this:
<a onclick="onLink Click(123);" href="......">f oo</a>
Unfortunately, if a user opens the link in a new tab (e.g right
click->open in new tab), my onLinkClick function does NOT get called.
Nor will it get called from middle-click, or if the link is dragged to a
tab or the tab bar, or all the other ways of following a link without
using a standard click.
This happens with Firefox (various versions, including the latest one -
1.5.0.1).
Does anyone know if there is a way to work around that and catch even
the "open in new tab" clicks/events?
There is no way to monitor if your links are opened in a new tab or if
navigation has been initiated by a mouse event.
I think what you really seek is to know if a link on your page was used
to initiate navigation using any method - new tab or window, dragged,
clicked, tabbed to, and so on - but that is simply not possible.
You can monitor right mouse clicks, but the user may be right-clicking
to add a bookmark, view the link properties, or some other function.
You'd have to monitor all other mouse buttons too, since middle-button
opens links in a new tab by default (in Firefox) and other buttons may
be programmed to do it too - many mice have 5 or more buttons, plus
modifiers.
And what if the user drags the link to another tab/window? You won't
get a click event because the mouseup occurs outside the window.
You have similar problems with IE opening links in other windows using
right-click, modifiers, other buttons or dragged links.
And what about other pointing devices and UI interaction methods?
You need to re-think UI works.
--
Rob