Наши волонтёры ещё не перевели данную статью на Русский. Присоединяйтесь к нам и помогите сделать эту работу!
Вы можете также прочитать эту статью на English (US).

An event handler property for right-click events on the window. Unless the default behavior is prevented (see examples below on how to do this), the browser context menu will activate (though IE8 has a bug with this and will not activate the context menu if a contextmenu event handler is defined). Note that this event will occur with any non-disabled right-click event and does not depend on an element possessing the "contextmenu" attribute.


window.oncontextmenu = funcRef;
//funcRef refers to the function to be called


These examples will disable right click on the page:

document.oncontextmenu = function () { // Use document as opposed to window for IE8 compatibility
   return false;

window.addEventListener('contextmenu', function (e) { // Not compatible with IE < 9
}, false);


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

Browser Compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) (Yes) ? ? ? ?
Feature Android Android Webview Chrome for Android Edge Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile
Basic support No support No support No support ? ? ? ? ? ?

Метки документа и участники

Внесли вклад в эту страницу: erikadoyle, jpmedley, cvrebert, Skoua, teoli, kosvrouvas, kscarfone, Sheppy, ethertank, Brettz9, ziyunfei, Rob W, Ryatt
Обновлялась последний раз: erikadoyle,