Execute a JavaScript when a context menu is triggered:
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.
Event Attribute | |||||
---|---|---|---|---|---|
oncontextmenu | Yes | Yes | Yes | Yes | Yes |
The oncontextmenu attribute is new in HTML5.
Value | Description |
---|---|
script | The script to be run on oncontextmenu |
Supported HTML tags: | All HTML elements |
---|
HTML DOM reference: oncontextmenu event