There was a scripting error on this page. While it is being addressed by site editors, you can view partial content below.

{{ DOMRef }}


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 compatibile with IE < 9
}, false);

Document Tags and Contributors

 Last updated by: teoli,