On Sep 4, 9:39 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
Dr J R Stockton said the following on 9/4/2007 6:16 PM:
In comp.lang.javascript message <4qWdnQ4jxLgdyUDb4p2d...@giganews.com>,
Tue, 4 Sep 2007 08:51:52, Randy Webb <HikksNotAtH...@aol.composted:
Thomas 'PointedEars' Lahn said the following on 9/3/2007 8:14 PM:
FAQ server wrote:
The oncontextmenu intrinsic event
My personal vote: The entry is wrong from start to finish. The question
being:
"How do I disable the right mouse button?"
And the only technically correct answer can only be:
"You can't".
Right. It's the wrong question. It should be "How do I disable the
context menu."
>
A most irresponsible suggestion.
It isn't a "suggestion", it is fact. You can not disable my right mouse
button. Although you are welcome to try to prove me wrong.
Of course a script can disable the right mouse button,
No it doesn't. Nor can it. Remember that this discussion got started
because Thomas wanted it semantically/technically correct.
or at least prevent it showing the usual menu.
It doesn't do that either. Reverse the mouse buttons and you can still
get that menu if you disable the right mouse button (try it).
This is not true. Software applications get the correct logical
button, regardless of which physical button generated the event. I
just tested it with my context function. I would have been shocked if
it failed for IE as the event is "contextmenu" and there is no need to
detect the button in JavaScript. It didn't break in the other agents
that use mouseup and button detection either. For the record, I have
tested in IE5, IE5.5, IE6, IE7, Firefox 2, Netscape 9, Opera 9 and
Safari Beta on Windows and all work with this logic in a contextmenu/
mouseup handler:
e = e || global.event;
if ((e.which == 3 || e.button & 4) || e.type == 'contextmenu') ...
If memory serves me right, at least one non-IE browser (Opera I think)
supports the contextmenu event. So you have to deal with cases where
both events fire. I believe the above works for Mac's as well,
despite the fact that most (all?) have a single mouse button. IIRC,
to generate a context click requires holding the button for a few
seconds. Certainly it should work in Mac IE if it supports the
contextmenu event.
There just is no one-line solution that is suitable for a FAQ entry on
how to disable the context menu. And there is definitely no answer
for how to disable a physical right click (or even a logical context
ckick.)
And I think it should be noted that it is insane to handle context
clicks unless you implement a custom context menu (and it is a very
rare case where that is appropriate.)