From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../globaleventhandlers/oncontextmenu/index.html | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 files/zh-cn/web/api/globaleventhandlers/oncontextmenu/index.html (limited to 'files/zh-cn/web/api/globaleventhandlers/oncontextmenu/index.html') 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 +--- +
{{ ApiRef("HTML DOM") }}
+ +

概述

+ +

获取或设置当前窗口contextmenu事件的事件处理函数。除非默认行为已经阻止了(看下面的例子是如何阻止的),否则右键菜单会被激活。注意此事件会发生在没有阻止右键事件的情况下而且这不取决于此元素是否拥有了"contextmenu"属性.

+ +

语法

+ +
window.oncontextmenu = funcRef;
+//funcRef是个函数引用
+
+ +

例子

+ +

这个例子会取消页面右键的功能:

+ +
window.oncontextmenu = function () {
+   return false;
+}
+//该窗口禁止使用右键
+
+ +

{{ languages( {"en": "en/DOM/window.oncontextmenu" } ) }}

-- cgit v1.2.3-54-g00ecf