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/open_event/index.html | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 files/zh-cn/web/api/websocket/open_event/index.html (limited to 'files/zh-cn/web/api/websocket/open_event/index.html') diff --git a/files/zh-cn/web/api/websocket/open_event/index.html b/files/zh-cn/web/api/websocket/open_event/index.html new file mode 100644 index 0000000000..a0d5e78dc7 --- /dev/null +++ b/files/zh-cn/web/api/websocket/open_event/index.html @@ -0,0 +1,42 @@ +--- +title: WebSocket.onopen +slug: Web/API/WebSocket/open_event +translation_of: Web/API/WebSocket/onopen +original_slug: Web/API/WebSocket/onopen +--- +

WebSocket.onopen属性定义一个事件处理程序,当{{domxref("WebSocket")}} 的连接状态{{domxref("WebSocket.readyState","readyState")}} 变为{{domxref("WebSocket.readyState","1")}}时调用;这意味着当前连接已经准备好发送和接受数据。这个事件处理程序通过 {{domxref("事件")}}(建立连接时)触发。

+ +

语法

+ +
aWebSocket.onopen = function(event) {
+  console.log("WebSocket is open now.");
+};
+ +

返回值

+ +

An {{domxref("EventListener")}}.

+ +

规范

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#handler-websocket-onopen', 'WebSocket: onopen')}}{{Spec2('HTML WHATWG')}}Initial definition
+ +

浏览器兼容性

+ + + +

{{Compat("api.WebSocket.onopen")}}

-- cgit v1.2.3-54-g00ecf