Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is oncontextmenu cross browser?

window.oncontextmenu = function() {
    return false;
};

Will this work on all major browsers such that the right click will not be initiated?

like image 866
David G Avatar asked Aug 28 '11 18:08

David G


People also ask

What is the use of oncontextmenu?

Definition and Usage. The oncontextmenu event occurs when the user right-clicks on an element to open the context menu. Note: Although the oncontextmenu event is supported in all browsers, the contextmenu attribute is currently only supported in Firefox.

When does the oncontextmenu attribute fire?

The oncontextmenu attribute fires when the user right-clicks on an element to open the context menu. Note: Although the oncontextmenu event is supported in all browsers, the contextmenu attribute is currently only supported in Firefox. The oncontextmenu attribute is part of the Event Attributes, and can be used on any HTML elements.

What is the contextmenu event?

The contextmenu event fires when the user attempts to open a context menu. This event is typically triggered by clicking the right mouse button, or by pressing the context menu key.

How do I hide a context menu item in the browser?

Once a context menu item has been added using contextMenus.create it's displayed in all browser tabs, but you can hide it by removing it with contextMenus.remove. The full list of supported contexts is available at menus.ContextType and includes contexts outside of a web page, such as bookmark items in the browser UI.


1 Answers

See this quirksmode page for a detailed compatibility table.

like image 60
Pekka Avatar answered Oct 19 '22 16:10

Pekka