blob: b0ee9e9d480d33ce0614bd7c79ba87eeba499b0c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
---
title: HTMLElement.contextMenu
slug: Web/API/HTMLElement/contextMenu
tags:
- API
translation_of: Web/API/HTMLElement/contextMenu
---
<div>{{APIRef("HTML DOM")}}{{deprecated_header()}}</div>
<p><code><strong>HTMLElement.contextMenu</strong></code> 特性指的是某一元素用{{htmlattrxref("contextmenu")}} 特性所创建的右键快捷菜单。该菜单本身源于 {{HTMLElement("menu")}} 元素所构建。</p>
<h2 id="语法">语法</h2>
<pre class="syntaxbox">var <var>elementContextMenu</var> = <var>element</var>.contextMenu;
</pre>
<h2 id="例子">例子</h2>
<pre class="brush: js">var contextMenu = document.getElementById("element").contextMenu;
// 修改条目1的标签
contextMenu.firstElementChild.label = "New label";
</pre>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("api.HTMLElement.contextMenu")}}</p>
<h2 id="相关链接">相关链接</h2>
<ul>
<li>{{htmlattrxref("contextmenu")}}</li>
<li>{{HTMLElement("menu")}}</li>
<li>{{HTMLElement("menuitem")}}</li>
</ul>
|