Deprecated
This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
The HTMLElement.contextMenu
property refers to the context menu assigned to an element using the contextmenu
attribute. The menu itself is created using the <menu>
element.
Syntax
var elementContextMenu = element.contextMenu;
Example
var contextMenu = document.getElementById("element").contextMenu; // Change the label of the first menu entry contextMenu.firstElementChild.label = "New label";
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
contextMenu | Chrome No support 45 — 61 | Edge No support ≤18 — 79 | Firefox Full support 1 | IE ? | Opera ? | Safari ? | WebView Android No support 45 — 61 | Chrome Android No support 45 — 61 | Firefox Android Full support 4 | Opera Android ? | Safari iOS ? | Samsung Internet Android No support 5.0 — 8.0 |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Non-standard. Expect poor cross-browser support.
- Non-standard. Expect poor cross-browser support.
- Deprecated. Not for use in new websites.
- Deprecated. Not for use in new websites.