diff options
Diffstat (limited to 'files/zh-cn/web/api/websocket/onclose/index.html')
-rw-r--r-- | files/zh-cn/web/api/websocket/onclose/index.html | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/websocket/onclose/index.html b/files/zh-cn/web/api/websocket/onclose/index.html new file mode 100644 index 0000000000..0ed1b7ffe1 --- /dev/null +++ b/files/zh-cn/web/api/websocket/onclose/index.html @@ -0,0 +1,37 @@ +--- +title: WebSocket.onclose +slug: Web/API/WebSocket/onclose +translation_of: Web/API/WebSocket/onclose +--- +<p>{{APIRef("Web Sockets API")}}</p> + +<p><strong><code>WebSocket.onclose</code></strong> 属性返回一个事件监听器,这个事件监听器将在 WebSocket 连接的{{domxref("WebSocket.readyState","readyState")}} 变为 <code>CLOSED</code>时被调用,它接收一个名字为“close”的 {{domxref("CloseEvent")}} 事件。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"><em>WebSocket</em>.onclose = function(event) { + console.log("WebSocket is closed now."); +};</pre> + +<h2 id="值">值</h2> + +<p>一个{{domxref("EventListener")}}.</p> + +<h2 id="文档">文档</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('HTML WHATWG', '#handler-websocket-onclose', 'WebSocket: onclose')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> |