HTML oncontextmenu Attribute
Definition and Usage
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.
Applies to
The oncontextmenu
attribute is part of the Event Attributes, and can be used on any HTML elements.
Elements | Event |
---|---|
All HTML elements | oncontextmenu |
Example
Execute a JavaScript when a context menu is triggered:
<div oncontextmenu="myFunction()" contextmenu="mymenu">
Browser Support
Event Attribute | |||||
---|---|---|---|---|---|
oncontextmenu | Yes | Yes | Yes | Yes | Yes |
Comments
Post a Comment