Closed Bug 309771 Opened 20 years ago Closed 20 years ago

onclick event fails to fire for middle and right clicks in 1.5 beta 1

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
major

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.
If you check in other browsers, you'll see that the behavior is the same. Try using 'onmouseup' instead to detect all click types.
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.
*** This bug has been marked as a duplicate of 156137 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.