From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/window/ondragdrop/index.html | 55 ++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 files/zh-cn/web/api/window/ondragdrop/index.html (limited to 'files/zh-cn/web/api/window/ondragdrop') diff --git a/files/zh-cn/web/api/window/ondragdrop/index.html b/files/zh-cn/web/api/window/ondragdrop/index.html new file mode 100644 index 0000000000..4a99f9da30 --- /dev/null +++ b/files/zh-cn/web/api/window/ondragdrop/index.html @@ -0,0 +1,55 @@ +--- +title: Window.ondragdrop +slug: Web/API/Window/ondragdrop +translation_of: Web/API/Window/ondragdrop +--- +
+

在Firefox 50中已删除,并且从未在任何其他浏览器中实行。 请改用现代标准的HTML5拖放功能。

+
+ +

摘要

+ +

一个事件处理程序,用于将拖放事件发送到窗口。

+ +

语法

+ +
window.ondragdrop = funcRef;
+window.addEventListener("dragdrop", funcRef, useCapturing);
+
+ +
+
funcRef 
+
要注册的事件处理函数。
+
+ +

Gecko({{ Bug(112288) }})中未实现window.ondragdrop属性和ondragdrop属性,您必须使用addEventListener。 有关详细信息,请参见addEventListener

+ +

示例

+ +

在拖放时触发alert

+ +

在此示例中,事件侦听器被添加到窗口(事件目标)。 如果从外部源将选项卡,链接,标记的文本或文件拖放到此窗口上,则会触发警报。 注意event.stopPropagation(); 阻止浏览器加载放置的标签,链接或文件。

+ +
<html>
+<head><title>dragdroptest</title>
+
+<script type="text/javascript">
+
+window.addEventListener("dragdrop", testfunc, false);
+
+function testfunc(event) {
+    alert("dragdrop!");
+    event.stopPropagation();
+}
+</script>
+
+</head>
+<body>
+I am bodytext
+</body>
+</html>
+
+ +

规范

+ +

不属于规范部分。

-- cgit v1.2.3-54-g00ecf