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 +++++++++++++++++ files/zh-cn/web/api/websocket/onclose/index.html | 37 ---------------- files/zh-cn/web/api/websocket/onerror/index.html | 45 -------------------- files/zh-cn/web/api/websocket/onmessage/index.html | 49 ---------------------- files/zh-cn/web/api/websocket/onopen/index.html | 41 ------------------ .../zh-cn/web/api/websocket/open_event/index.html | 42 +++++++++++++++++++ 6 files changed, 80 insertions(+), 172 deletions(-) create mode 100644 files/zh-cn/web/api/websocket/close_event/index.html delete mode 100644 files/zh-cn/web/api/websocket/onclose/index.html delete mode 100644 files/zh-cn/web/api/websocket/onerror/index.html delete mode 100644 files/zh-cn/web/api/websocket/onmessage/index.html delete mode 100644 files/zh-cn/web/api/websocket/onopen/index.html create mode 100644 files/zh-cn/web/api/websocket/open_event/index.html (limited to 'files/zh-cn/web/api') 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
diff --git a/files/zh-cn/web/api/websocket/onclose/index.html b/files/zh-cn/web/api/websocket/onclose/index.html deleted file mode 100644 index 0ed1b7ffe1..0000000000 --- a/files/zh-cn/web/api/websocket/onclose/index.html +++ /dev/null @@ -1,37 +0,0 @@ ---- -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
diff --git a/files/zh-cn/web/api/websocket/onerror/index.html b/files/zh-cn/web/api/websocket/onerror/index.html deleted file mode 100644 index 996ad55472..0000000000 --- a/files/zh-cn/web/api/websocket/onerror/index.html +++ /dev/null @@ -1,45 +0,0 @@ ---- -title: WebSocket.onerror -slug: Web/API/WebSocket/onerror -translation_of: Web/API/WebSocket/onerror ---- -

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

- -

The WebSocket.onerror property returns the event listener to be called when an error occurs. This is a simple event named "error".

- -

WebSocket.onerror 属性中,你可以定义一个发生错误时执行的回调函数,此事件的事件名为"error"

- -

语法

- -
WebSocket.onerror = function(event) {
-  console.error("WebSocket error observed:", event);
-};
- -

- -

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

- -

Specifications

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

浏览器兼容性

- - - -

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

diff --git a/files/zh-cn/web/api/websocket/onmessage/index.html b/files/zh-cn/web/api/websocket/onmessage/index.html deleted file mode 100644 index 4bdcb51039..0000000000 --- a/files/zh-cn/web/api/websocket/onmessage/index.html +++ /dev/null @@ -1,49 +0,0 @@ ---- -title: WebSocket.onmessage -slug: Web/API/WebSocket/onmessage -tags: - - API - - Web API - - WebSocket - - 参考 - - 属性 -translation_of: Web/API/WebSocket/onmessage ---- -

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

- -

WebSocket.onmessage 属性是一个当收到来自服务器的消息时被调用的 {{event("Event_handlers", "event handler")}}。它由一个{{domxref("MessageEvent")}}调用。

- -

语法

- -
aWebSocket.onmessage = function(event) {
-  console.debug("WebSocket message received:", event);
-};
- -

- -

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

- -

规范

- - - - - - - - - - - - - - - - -
规范状态注释
{{SpecName('HTML WHATWG', '#handler-websocket-onmessage', 'WebSocket: onmessage')}}{{Spec2('HTML WHATWG')}}初始定义
- -

浏览器兼容性

- - - -

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

diff --git a/files/zh-cn/web/api/websocket/onopen/index.html b/files/zh-cn/web/api/websocket/onopen/index.html deleted file mode 100644 index 067c9057bc..0000000000 --- a/files/zh-cn/web/api/websocket/onopen/index.html +++ /dev/null @@ -1,41 +0,0 @@ ---- -title: WebSocket.onopen -slug: Web/API/WebSocket/onopen -translation_of: 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")}}

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