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/websocket/onclose/index.html | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 files/zh-cn/web/api/websocket/onclose/index.html (limited to 'files/zh-cn/web/api/websocket/onclose') 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 +--- +

{{APIRef("Web Sockets API")}}

+ +

WebSocket.onclose 属性返回一个事件监听器,这个事件监听器将在 WebSocket 连接的{{domxref("WebSocket.readyState","readyState")}} 变为 CLOSED时被调用,它接收一个名字为“close”的 {{domxref("CloseEvent")}} 事件。

+ +

语法

+ +
WebSocket.onclose = function(event) {
+  console.log("WebSocket is closed now.");
+};
+ +

+ +

一个{{domxref("EventListener")}}.

+ +

文档

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#handler-websocket-onclose', 'WebSocket: onclose')}}{{Spec2('HTML WHATWG')}}Initial definition
-- cgit v1.2.3-54-g00ecf