Nuestros voluntarios aún no han traducido este artículo al Español. ¡Únete a nosotros y ayúdanos a traducirlo!
También puedes leer el artículo en English (US).

The oncontextmenu property of the GlobalEventHandlers mixin is an EventHandler that processes contextmenu events.

The contextmenu event fires when the right mouse button is clicked on the window. Unless the default behavior is prevented, the browser context menu will activate.


window.oncontextmenu = funcRef;


funcRef refers to the function to be called.


These examples will disable right clicks on the page.

// Option 1: event handler
window.oncontextmenu = function () {
  return false;

// Option 2: event listener
window.addEventListener('contextmenu', function (e) {
}, false);


Specification Status Comment
HTML Living Standard
The definition of 'oncontextmenu' in that specification.
Living Standard  

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support YesEdge Full support YesFirefox Full support YesIE ? Opera ? Safari ? WebView Android No support NoChrome Android No support NoEdge Mobile ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?


Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

Unless the default behavior is prevented, the browser context menu will activate upon right-click. However, IE8 has a bug with this and will not activate the context menu if a contextmenu event handler is defined.

Etiquetas y colaboradores del documento

Última actualización por: mfluehr,