blob: 57247d931e33723dd87594d579767789335a8909 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
---
title: WebSocket.readyState
slug: Web/API/WebSocket/readyState
tags:
- Web API
- WebSocket
translation_of: Web/API/WebSocket/readyState
---
<p>{{APIRef("Web Sockets API")}}</p>
<h2 id="概要">概要</h2>
<p>返回当前 {{domxref("WebSocket")}} 的链接状态,只读。</p>
<h2 id="语法">语法</h2>
<pre class="syntaxbox notranslate">var readyState = <em>WebSocket</em>.readyState;</pre>
<h2 id="值">值</h2>
<p>以下其中之一</p>
<dl>
<dt>0 (<code>WebSocket.CONNECTING</code>)</dt>
<dd>正在链接中</dd>
<dt>1 (<code>WebSocket.OPEN</code>)</dt>
<dd>已经链接并且可以通讯</dd>
<dt>2 (<code>WebSocket.CLOSING</code>)</dt>
<dd>连接正在关闭</dd>
<dt>3 (<code>WebSocket.CLOSED</code>)</dt>
<dd>连接已关闭或者没有链接成功</dd>
</dl>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<tbody>
<tr>
<th>Specification</th>
<th>Status</th>
<th>Comment</th>
</tr>
<tr>
<td><a class="external external-icon" href="https://html.spec.whatwg.org/multipage/web-sockets.html#dom-websocket-readystate" hreflang="en" lang="en">HTML Living Standard<br>
<small lang="en-US">The definition of 'WebSocket.readyState' in that specification.</small></a></td>
<td><span class="spec-Living">Living Standard</span></td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{Compat("api.WebSocket.readyState")}}</p>
<p>
<audio class="hidden"></audio>
</p>
|