FAQ Topic - How do I suppress a context menu (right-click menu)? (2012-02-22)


FAQ server

FAQ Topic - How do I suppress a context menu (right-click

A context menu, often triggered by right-click, can be requested by the
user in a few ways. For example, on windows, shift + F10 and on macs,
click-and-hold. Other input devices exist and mouse buttons can be
configured, making the term "right click" a misnomer, in context.

In browsers that allow it, a script can suppress the context menu by
returning false from an object's `oncontextmenu` event handler.

document.oncontextmenu = function() {
return false;

Some browsers lack context menus (e.g. iphone). Browsers that have
context menus do not always have a scriptable event for them. Some
browsers can be configured to disallow scripts from detecting context
menu events (IE, Opera); others may fire the event but be configured to
disallow scripts from suppressing the context menu (Firefox,Seamonkey).

Even when the context menu has been suppressed, it will still be
possible to view/save the source code and to save images.

<URL: http://en.wikipedia.org/wiki/Context_menu>
<URL: http://kb.mozillazine.org/Ui.click_hold_context_menus>
<URL: http://support.microsoft.com/kb/823057>
<URL: http://stackoverflow.com/questions/...nu-picking-up-the-right-click/1902730#1902730>
<URL: http://support.mozilla.com/en-US/kb/Javascript#Advanced_JavaScript_settings>
<URL: http://msdn.microsoft.com/en-us/library/ms536914(VS.85).aspx>

The complete comp.lang.javascript FAQ is at


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