aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/globaleventhandlers/onclose
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/globaleventhandlers/onclose
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/globaleventhandlers/onclose')
-rw-r--r--files/zh-cn/web/api/globaleventhandlers/onclose/index.html67
1 files changed, 67 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/globaleventhandlers/onclose/index.html b/files/zh-cn/web/api/globaleventhandlers/onclose/index.html
new file mode 100644
index 0000000000..f7061e8243
--- /dev/null
+++ b/files/zh-cn/web/api/globaleventhandlers/onclose/index.html
@@ -0,0 +1,67 @@
+---
+title: GlobalEventHandlers.onclose
+slug: Web/API/GlobalEventHandlers/onclose
+tags:
+ - API
+ - Dialog
+ - Event Handler
+ - GlobalEventHandlers
+ - HTML DOM
+ - 参考
+ - 实验性的
+ - 属性
+ - 需要示例
+translation_of: Web/API/GlobalEventHandlers/onclose
+---
+<div>{{ApiRef("HTML DOM")}} {{SeeCompatTable}}</div>
+
+<p>{{domxref("GlobalEventHandlers")}} mixin 的 <code><strong>onclose</strong></code> 属性是一个 {{domxref("EventHandler")}}, 用来处理发送给 {{HTMLElement("dialog")}} 元素的 {{event("close")}} 事件。</p>
+
+<p>当用户关闭一个 <code>&lt;dialog&gt;</code> 时,<code>close</code> 事件将被触发。</p>
+
+<div class="blockIndicator note">
+<p><strong>注意:</strong>如果要处理 window 的关闭,使用 {{domxref("WindowEventHandlers.onbeforeunload", "onbeforeunload")}} 或 {{domxref("WindowEventHandlers.onunload", "onunload")}}.</p>
+</div>
+
+<h2 id="语法">语法</h2>
+
+<pre class="notranslate"><em>target</em>.onclose = <em>functionRef</em>;</pre>
+
+<h3 id="参数">参数</h3>
+
+<p><code>functionRef</code> 是一个函数名称或 <a href="/en-US/docs/Web/JavaScript/Reference/Operators/function">函数表达式</a>。 该函数接受一个 {{domxref("Event")}} 对象作为它唯一的参数。</p>
+
+<p>每次只能给一个对象添加 <code>onclose</code> 回调。 你可能更喜欢使用 {{domxref("EventTarget.addEventListener()")}} 方法,因为它更加灵活。</p>
+
+<h2 id="规范">规范</h2>
+
+<table class="spectable standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">文档</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML WHATWG','webappapis.html#handler-onclose','onclose')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<div class="hidden">
+<p>The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+</div>
+
+<p>{{Compat("api.GlobalEventHandlers.onclose")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>{{event("close")}} 事件</li>
+ <li>HTML {{HTMLElement("dialog")}} 元素</li>
+ <li>相关事件回调: {{domxref("GlobalEventHandlers.oncancel")}}</li>
+</ul>