HTMLElement.contextMenu

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

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic support
DeprecatedNon-standard
Chrome ? Edge Full support YesFirefox Full support 1IE ? Opera ? Safari ? WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full 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.

See also

Document Tags and Contributors

Contributors to this page: ExE-Boss, sideshowbarker, fscholz, valtlai, Sheppy, Sebastianz
Last updated by: ExE-Boss,