From 9b97f9f4a1f580cbf582fb4bebabbccaab8e5dda Mon Sep 17 00:00:00 2001 From: MDN Date: Thu, 16 Dec 2021 00:52:08 +0000 Subject: [CRON] sync translated content --- .../zh-cn/web/api/websocket/close_event/index.html | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 files/zh-cn/web/api/websocket/close_event/index.html (limited to 'files/zh-cn/web/api/websocket/close_event') diff --git a/files/zh-cn/web/api/websocket/close_event/index.html b/files/zh-cn/web/api/websocket/close_event/index.html new file mode 100644 index 0000000000..b168dace44 --- /dev/null +++ b/files/zh-cn/web/api/websocket/close_event/index.html @@ -0,0 +1,38 @@ +--- +title: WebSocket.onclose +slug: Web/API/WebSocket/close_event +translation_of: Web/API/WebSocket/onclose +original_slug: 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