473,395 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

FAQ Topic - How do I disable the right mouse button?

-----------------------------------------------------------------------
FAQ Topic - How do I disable the right mouse button?
-----------------------------------------------------------------------

The oncontextmenu intrinsic event is the only safe and reliable
method. Of the other approaches often presented, most depend on
an alert box interrupting the process and rarely work. Note that
oncontextmenu is a non-standard event and is not supported on
all browsers.
` <body oncontextmenu="return false"`
===
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://jibbering.com/faq/index.html.
The FAQ workers are a group of volunteers. The sendings of these
daily posts are proficiently hosted by www.pair.com.

Sep 3 '07 #1
8 3643
FAQ server wrote:
The oncontextmenu intrinsic event
As I have pointed out in my still unanswered e-mail to both current FAQ
maintainers about 20 days ago (along with other suggestions and comments),
that wording is wrong. `oncontextmenu' is a proprietary event handler,
not an intrinsic event as defined by and in the HTML 4.01 Specification:

http://www.w3.org/TR/html401/interac...ts.html#events
is the only safe and reliable method.
As I also have pointed out, because it is proprietary and not standardized,
it runs the risk of being not well supported, if supported at all, and so it
is not a safe and reliable method at all.
Of the other approaches often presented, most depend on
an alert box interrupting the process and rarely work. Note that
oncontextmenu is a non-standard event
It is a non-standard (i.e. proprietary) event *handler*. The corresponding
event would be `contextmenu'. It is just that the MSDN Library is unable to
make that important distinction to date (when MS begins to implement DOM
Level 2+ Events, they will finally have to.) In that sense, the HTML 4.01
Specification which uses the same (wrong) terminology has been updated by
the W3C DOM Level 2 Events Specification as indicated by the included note
in the aforementioned subsection of HTML 4.01:

http://www.w3.org/TR/DOM-Level-2-Events/
and is not supported on all browsers.
There is the all-too-obvious contradiction to the above statements.
PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Sep 4 '07 #2
Thomas 'PointedEars' Lahn said the following on 9/3/2007 8:14 PM:
FAQ server wrote:
>The oncontextmenu intrinsic event

As I have pointed out in my still unanswered e-mail to both current FAQ
maintainers about 20 days ago (along with other suggestions and comments),
that wording is wrong.
20 days ago was about the time I changed the email address in the FAQ to
the current one. If you sent an email to the old address then it would
explain why I haven't received it. If you sent it to cl****@comcast.net
then I honestly do not know why I have not received it unless it didn't
have FAQ in the Subject line of the email. If you would, please forward
it or re-send it to cl****@comcast.net and make sure the Subject Line
has FAQ in it so that the spam filter doesn't catch it by mistake.

Although personally, I would prefer that comments regarding the FAQ -
and its contents - be posted to the group so that it can be reviewed and
commented on by the group.

<snip>

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
FAQ Notes: http://www.jibbering.com/faq/faq_notes/faq_notes.html
ECMAScript Language Specification via FAQ2.6
Sep 4 '07 #3
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".

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Sep 4 '07 #4
Randy Webb wrote:
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".
My personal vote is to keep

<body oncontextmenu="return false">

--
Bart

Sep 4 '07 #5
In comp.lang.javascript message <4q*********************@giganews.com>,
Tue, 4 Sep 2007 08:51:52, Randy Webb <Hi************@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".
A most irresponsible suggestion. Of course a script can disable the
right mouse button, or at least prevent it showing the usual menu. One
condition is sufficient, though probably not entirely necessary : that
the browser be IE6 running in XP sp2.

For me, <body oncontextmenu="return false" disables it in IE6,
but not in Opera 9.23.

Therefore, an acceptable answer giving that code must state clearly that
it works in some but not all browsers.

Consider -
User, viewing page : The right mouse button does not now work!
Adviser, reading FAQ : It cannot be disabled; it must be broken.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/- FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)
Sep 4 '07 #6
FAQEditor said the following on 9/4/2007 8:43 AM:
Thomas 'PointedEars' Lahn said the following on 9/3/2007 8:14 PM:
>FAQ server wrote:
>>The oncontextmenu intrinsic event

As I have pointed out in my still unanswered e-mail to both current FAQ
maintainers about 20 days ago (along with other suggestions and
comments),
that wording is wrong.

20 days ago was about the time I changed the email address in the FAQ to
the current one. If you sent an email to the old address then it would
explain why I haven't received it. If you sent it to cl****@comcast.net
then I honestly do not know why I have not received it unless it didn't
have FAQ in the Subject line of the email. If you would, please forward
it or re-send it to cl****@comcast.net and make sure the Subject Line
has FAQ in it so that the spam filter doesn't catch it by mistake.
Have you tried to resend that email? I have not yet received any from you.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
FAQ Notes: http://www.jibbering.com/faq/faq_notes/faq_notes.html
ECMAScript Language Specification via FAQ2.6
Sep 6 '07 #7
FAQEditor wrote:
FAQEditor said the following on 9/4/2007 8:43 AM:
>Thomas 'PointedEars' Lahn said the following on 9/3/2007 8:14 PM:
>>FAQ server wrote:
The oncontextmenu intrinsic event
As I have pointed out in my still unanswered e-mail to both current FAQ
maintainers about 20 days ago (along with other suggestions and
comments),
that wording is wrong.
20 days ago was about the time I changed the email address in the FAQ to
the current one. If you sent an email to the old address then it would
explain why I haven't received it. If you sent it to cl****@comcast.net
then I honestly do not know why I have not received it unless it didn't
have FAQ in the Subject line of the email. If you would, please forward
it or re-send it to cl****@comcast.net and make sure the Subject Line
has FAQ in it so that the spam filter doesn't catch it by mistake.

Have you tried to resend that email? I have not yet received any from you.
Sorry, I'm currently too busy doing my (RL) job.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Sep 7 '07 #8
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.)

Oct 6 '07 #9

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

Similar topics

4
by: Lijun Yang | last post by:
Hey, I am able to disable the right mouse button on images for netscape and IE but it won't work for Opera. Here is the code: // start of the code var clickmessage="Sorry, you don't have...
6
by: nntp | last post by:
I have a set of links which I want search engines to crawl them, but I want to disable them from my visitors, so I will ask the link owners to pay me to let me enable them. <a disabled...
9
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I disable the right mouse button? -----------------------------------------------------------------------...
4
by: Vincent | last post by:
I have created a drag and drop scheduler within Microsoft access. One of our bug testers was doing some testing and noticed that the drag and drop gets messed up if they press both the left and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.