aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/window/ondragdrop
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/window/ondragdrop
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/window/ondragdrop')
-rw-r--r--files/zh-cn/web/api/window/ondragdrop/index.html55
1 files changed, 55 insertions, 0 deletions
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
+---
+<div class="warning">
+<p>在Firefox 50中已删除,并且从未在任何其他浏览器中实行。 请改用现代标准的<a href="/en-US/docs/Web/API/HTML_Drag_and_Drop_API">HTML5拖放</a>功能。</p>
+</div>
+
+<h2 id="Summary" name="Summary">摘要</h2>
+
+<p>一个事件处理程序,用于将拖放事件发送到窗口。</p>
+
+<p><font face="x-locale-heading-primary, zillaslab, Palatino, Palatino Linotype, x-locale-heading-secondary, serif"><span style="font-size: 37.33327865600586px;"><strong>语法</strong></span></font></p>
+
+<pre class="eval notranslate"><s>window.ondragdrop = funcRef;</s>
+window.addEventListener("dragdrop", funcRef, useCapturing);
+</pre>
+
+<dl>
+ <dt>funcRef </dt>
+ <dd>要注册的事件处理函数。</dd>
+</dl>
+
+<p><a href="/zh-CN/docs/Web/API/Window/en/Gecko">Gecko</a>({{ Bug(112288) }})中未实现<code>window.ondragdrop</code>属性和<code>ondragdrop</code>属性,您必须使用<code>addEventListener</code>。 有关详细信息,请参见<a href="/zh-CN/docs/Web/API/Window/en/DOM/element.addEventListener">addEventListener</a>。</p>
+
+<p><font face="x-locale-heading-primary, zillaslab, Palatino, Palatino Linotype, x-locale-heading-secondary, serif"><span style="font-size: 37.33327865600586px;"><strong>示例</strong></span></font></p>
+
+<h3 id="Fire_an_alert_on_dragdrop" name="Fire_an_alert_on_dragdrop">在拖放时触发alert</h3>
+
+<p>在此示例中,事件侦听器被添加到窗口(事件目标)。 如果从外部源将选项卡,链接,标记的文本或文件拖放到此窗口上,则会触发警报。 注意<code>event.stopPropagation()</code>; 阻止浏览器加载放置的标签,链接或文件。</p>
+
+<pre class="notranslate">&lt;html&gt;
+&lt;head&gt;&lt;title&gt;dragdroptest&lt;/title&gt;
+
+&lt;script type="text/javascript"&gt;
+
+window.addEventListener("dragdrop", testfunc, false);
+
+function testfunc(event) {
+ alert("dragdrop!");
+ event.stopPropagation();
+}
+&lt;/script&gt;
+
+&lt;/head&gt;
+&lt;body&gt;
+I am bodytext
+&lt;/body&gt;
+&lt;/html&gt;
+</pre>
+
+<p><font face="x-locale-heading-primary, zillaslab, Palatino, Palatino Linotype, x-locale-heading-secondary, serif"><span style="font-size: 37.33327865600586px;"><strong>规范</strong></span></font></p>
+
+<p>不属于规范部分。<span class="external"> </span></p>