I would like to open a new tab (or window, depending on the user’s browser settings) with javascript when the user clicks on a link. I have seen other sites who do that, without being flagged as popups by firefox. My link is flagged as a popup though. Maybe it’s because it is necessary that the domain stay the same (which is not my case) ?
Is there a way to prevent my link to be flagged as popup, seeing as the new tab event is triggered by a mouse click ?
Thanks
What I would probably do — depending on the exact requirements — is, instead of setting an
onclickhandler, set anonmouseuphandler, and instead of having the handler open the link, have the handler set the link’shref— and not override the browser’s default behavior. (That last part isn’t actually important behavior-wise, since there’s no major default on-mouse-up behavior, but it’s important readability-wise!) Then, after the handler finishes, the browser will act just as if the user had clicked on a normal link with thathref: assuming typical Firefox settings, a left-click will open the link in the same tab, a middle-click will open it in a new tab, and a right-click will open a context-menu with options such as “Open Link in New Window” and “Open Link in New Tab”.