aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/websocket/open_event
diff options
context:
space:
mode:
authorMDN <actions@users.noreply.github.com>2021-12-16 00:52:08 +0000
committerMDN <actions@users.noreply.github.com>2021-12-16 00:52:08 +0000
commit9b97f9f4a1f580cbf582fb4bebabbccaab8e5dda (patch)
tree513e8e35a07a3fd1dc45a5415425fd3780075d51 /files/zh-cn/web/api/websocket/open_event
parent7f7c1b96a524c16de813516cc1b7ed3b773ae7ad (diff)
downloadtranslated-content-9b97f9f4a1f580cbf582fb4bebabbccaab8e5dda.tar.gz
translated-content-9b97f9f4a1f580cbf582fb4bebabbccaab8e5dda.tar.bz2
translated-content-9b97f9f4a1f580cbf582fb4bebabbccaab8e5dda.zip
[CRON] sync translated content
Diffstat (limited to 'files/zh-cn/web/api/websocket/open_event')
-rw-r--r--files/zh-cn/web/api/websocket/open_event/index.html42
1 files changed, 42 insertions, 0 deletions
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
+---
+<p><strong><code>WebSocket.onopen</code></strong>属性定义一个事件处理程序,当{{domxref("WebSocket")}} 的连接状态{{domxref("WebSocket.readyState","readyState")}} 变为{{domxref("WebSocket.readyState","1")}}时调用;这意味着当前连接已经准备好发送和接受数据。这个事件处理程序通过 {{domxref("事件")}}(建立连接时)触发。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox notranslate"><em>aWebSocket</em>.onopen = function(event) {
+ console.log("WebSocket is open now.");
+};</pre>
+
+<h2 id="返回值">返回值</h2>
+
+<p>An {{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-onopen', 'WebSocket: onopen')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.WebSocket.onopen")}}</p>