473,624 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JS onClick not executing when opening in new tab (Firefox)

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.
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?

Thanks!

Mar 22 '06 #1
1 6290
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
Mar 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
61424
by: Mike Gratee | last post by:
Is it possible to use JavaScript to cause the browser to click a link on a page and have the browser act exactly like the user had clicked on the link directly? In other words, I need to programmatically issue a JavaScript statement which causes the browser to act just like the user clicked on a link in my page. And if that link has an onClick JS event defined, I'd want that onClick event to execute too, exactly the same as if the user...
10
23269
by: Noozer | last post by:
Is it possible to detect where on a page the click occurred when the OnClick event of the BODY tag is fired? Thx
10
67748
by: Eric-Sebastien Lachance | last post by:
Hey there, I decided to just create a 100% height and width div that filled the space over a background header image, and add an onclick event to redirect to the my index... Doesn't seem to work in FireFox only, just in IE. Here's the code: <div id="headerimg"><div style="width: 100%; height: 100%; cursor: hand; cursor: pointer;" onclick="top.location.href('http://www.monamouchtim.com/');">&nbsp;</div></div>
53
81701
by: usenet | last post by:
See <ul> <li><a name="link1" onClick="alert(this.name);return false;" href="#">Link1</a></li> <li><a name="link2" href="javascript:alert(this);">Link2</a></li> <li>Item 3</li> </ul> Clicking on the first list item gives me "link1" because "this" refers
6
7167
by: Nx | last post by:
i've got it all working nicely in firefox, but whenever i test it in IE none of the onclick events are triggered. i'm using an xsl to transform an rss feed into a photogallery. when i try to use setAttribute FF and safari work, but IE stops working when i used addEventListener and attachEvent safari stops working and when i tried .onClick,none of them worked being fairly inexperienced (but learning fast), i figure i'm doing it
2
3033
by: deergregoryd | last post by:
I've got some PHP and javascript working together to create a marginless image popup from another arbitrary image. This works perfectly in Firefox, but IE bombs and I'm not really knowledgable about Javascript to be able to tell immediately why. Here's the relevant code from the page: <a href="#" onClick="window.open('http://www.somesite.com/popup.php?image=popup.jpg', 'popup', 'width=737,height=492, directories=no, location=no,...
4
13549
by: sameergn | last post by:
Hi, I have an image in my HTML form which has onclick() handler. There is also a submit button and a text box. Whenever text box has focus and user presses enter, the onclick() event of image is fired with event.keyCode as undefined. I was expecting that the form would get submitted. I tried returning from onclick() handler if keyCode is null, but the
12
9545
by: Andrew C | last post by:
Hi, folks. I've recently been doing a few simple tests and experiments. As a result, I've noticed that, in dealing with 'onclick', IE seems less able than Firefox to keep up with rapid clicking. In fact, Firefox seems to be able to keep up with me no matter how rapidly I click, whereas IE... well, doesn't! The following snippet of code demonstrates this (on my machine it does anyway):
17
2666
by: yawnmoth | last post by:
http://www.frostjedi.com/terra/scripts/demo/this-alert.html http://www.frostjedi.com/terra/scripts/demo/this-alert2.html Why, when you click in the black box, do the alert boxes say different things? Shouldn't they say the same thing?
0
8236
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8679
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8621
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8475
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7159
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5563
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4079
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.