diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/globaleventhandlers/oncontextmenu/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/globaleventhandlers/oncontextmenu/index.html')
-rw-r--r-- | files/zh-cn/web/api/globaleventhandlers/oncontextmenu/index.html | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/globaleventhandlers/oncontextmenu/index.html b/files/zh-cn/web/api/globaleventhandlers/oncontextmenu/index.html new file mode 100644 index 0000000000..b8f5b92aa3 --- /dev/null +++ b/files/zh-cn/web/api/globaleventhandlers/oncontextmenu/index.html @@ -0,0 +1,28 @@ +--- +title: GlobalEventHandlers.oncontextmenu +slug: Web/API/GlobalEventHandlers/oncontextmenu +translation_of: Web/API/GlobalEventHandlers/oncontextmenu +--- +<div>{{ ApiRef("HTML DOM") }}</div> + +<h3 id="Summary" name="Summary">概述</h3> + +<p>获取或设置当前窗口contextmenu事件的事件处理函数。除非默认行为已经阻止了(看下面的例子是如何阻止的),否则右键菜单会被激活。注意此事件会发生在没有阻止右键事件的情况下而且这不取决于此元素是否拥有了<a href="http://hacks.mozilla.org/2011/11/html5-context-menus-in-firefox-screencast-and-code/" title="http://hacks.mozilla.org/2011/11/html5-context-menus-in-firefox-screencast-and-code/">"contextmenu"属性</a>.</p> + +<h3 id="Syntax" name="Syntax">语法</h3> + +<pre class="eval">window.oncontextmenu = funcRef; +//funcRef是个函数引用 +</pre> + +<h3 id="Example" name="Example">例子</h3> + +<p>这个例子会取消页面右键的功能:</p> + +<pre class="eval">window.oncontextmenu = function () { + return false; +} +//该窗口禁止使用右键 +</pre> + +<p>{{ languages( {"en": "en/DOM/window.oncontextmenu" } ) }}</p> |