--- title: WebSocket.readyState slug: Web/API/WebSocket/readyState tags: - Web API - WebSocket translation_of: Web/API/WebSocket/readyState ---
{{APIRef("Web Sockets API")}}
返回当前 {{domxref("WebSocket")}} 的链接状态,只读。
var readyState = WebSocket.readyState;
以下其中之一
WebSocket.CONNECTING)WebSocket.OPEN)WebSocket.CLOSING)WebSocket.CLOSED)| Specification | Status | Comment | 
|---|---|---|
| HTML Living Standard The definition of 'WebSocket.readyState' in that specification. | Living Standard | Initial definition | 
{{Compat("api.WebSocket.readyState")}}