By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,504 Members | 1,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,504 IT Pros & Developers. It's quick & easy.

oncontextmenu and preventDefault for right clicks in Firefox

P: n/a
I want to detect and act on right button clicks in Firefox. The problem
was I kept getting the context menu pop up on right button clicks, even
when I called event.preventDefault(). I had assumed that this would
prevent the context menu which seems to be the default action. Why does
this not prevent the context menu from popping up?

Someone mentioned using the "contextmenu" event which I had assumed was
IE-only. I could not find it in the Mozilla documentation but it seems
to work in Firefox. When I used event.preventDefault() in the
conextmenu event handler it took care of the problem.

One other strange thing. The mousedown event from a right mouse click
has button=2 as expected but the corresponding mouseup event has
button=0. Why is that?

--Charlie Crowley

Dec 2 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Charlie wrote:
I want to detect and act on right button clicks in Firefox. The problem
was I kept getting the context menu pop up on right button clicks, even
when I called event.preventDefault(). I had assumed that this would
prevent the context menu which seems to be the default action. Why does
this not prevent the context menu from popping up?
Try these:
http://developer.mozilla.org/en/docs...preventDefault
http://developer.mozilla.org/en/docs...topPropagation

preventDefault() doesn't stop the event from bubbling further up the
tree...
stopPropagation() hides the event from other handlers further up the
DOM tree.

/John

Jan 23 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.