HTMLElement.contextMenu

已废弃
该特性已经从 Web 标准中删除,虽然一些浏览器目前仍然支持它,但也许会在未来的某个时间停止支持,请尽量不要使用该特性。

HTMLElement.contextMenu 特性指的是某一元素用contextmenu 特性所创建的右键快捷菜单。该菜单本身源于 <menu> 元素所构建。

语法

var elementContextMenu = element.contextMenu;

例子

var contextMenu = document.getElementById("element").contextMenu; 

// 修改条目1的标签
contextMenu.firstElementChild.label = "New label";

浏览器兼容性

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.

相关链接

文档标签和贡献者

标签: 
此页面的贡献者: mdnwebdocs-bot, zhangchen, xiaokk06, 1Cr18Ni9
最后编辑者: mdnwebdocs-bot,