Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!

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.

Syntax

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

Example

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
    e.preventDefault();
}, false);

Specifications

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

ドキュメントのタグと貢献者

 このページの貢献者: cvrebert, Skoua, teoli, kosvrouvas, kscarfone, Sheppy, ethertank, Brettz9, ziyunfei, Rob W, Ryatt
 最終更新者: cvrebert,