Closed
Bug 309771
Opened 19 years ago
Closed 19 years ago
onclick event fails to fire for middle and right clicks in 1.5 beta 1
Categories
(Firefox :: General, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 156137
People
(Reporter: y5, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4) Gecko/20050908 Firefox/1.4 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b4) Gecko/20050908 Firefox/1.4 Attaching an onclick event handler to an element works fine for left clicks, but never fires off for middle- or right-clicks. Tested in Firefox 1.5 beta 1. Reproducible: Always Steps to Reproduce: 1. Attach an onclick event to any element on the page (ex: document.getElementById("elementname").onclick = ClickFunction;) 2. Create the ClickFunction() { alert("clicked"; ); Actual Results: Middle- or right-clicking the element will never fire off ClickFunction(), and will instead perform default action. Expected Results: The function should have been called.
Comment 1•19 years ago
|
||
If you check in other browsers, you'll see that the behavior is the same. Try using 'onmouseup' instead to detect all click types.
Reporter | ||
Comment 2•19 years ago
|
||
True, I've noticed that too. What brought up the bug report in the first place is how to detect a middle-click. onmouseup is not sufficient if I need to cancel the default action of the right or middle click. I understand that oncontextmenu works to cancel right clicks. But there is no (documented?) event to capture middle-clicking a link and cancel the default action of opening a new tab. Attaching mouseup to an anchor element and cancelling the default action on middle-click does not prevent a new tab from being opened (and rightly so). But by including middle and right-clicks in the onclick event handler, it would solve the problem cleanly. IIRC (and I might be wrong) earlier releases of Fx 1.0 was able to catch the middle click using the onclick handler.
Comment 3•19 years ago
|
||
*** This bug has been marked as a duplicate of 156137 ***
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•