FAQ Topic - How do I disable the right mouse button? (2010-02-10)

F

FAQ server

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

The nonstandard ` contextmenu ` event is not widely supported.
Browsers that do support it may be configured to prevent scripts from
accessing that event.

Example:

<body oncontextmenu="return false">

Disables the context menu where supported. Note that this will not
prevent users from viewing your source code or copying images. To
discourage copying, provide a copyright notice.

http://msdn.microsoft.com/en-us/library/ms536914(VS.85).aspx

https://developer.mozilla.org/En/DOM/Window.oncontextmenu


The complete comp.lang.javascript FAQ is at
http://jibbering.com/faq/
 
D

David Mark

It's not always the right mouse button (and some mice have but one button).
The nonstandard ` contextmenu ` event is not widely supported.
Browsers that do support it may be configured to prevent scripts from
accessing that event.

What about mouseup? That works where contextmenu fails (with the same
caveats). You have to check that it is not the "left" (or middle)
button though (logically, they are considered left and right, even when
this is not the case physically).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top