WebSocket:readyState 属性
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
备注: 此特性在 Web Worker 中可用。
WebSocket.readyState
只读属性返回 WebSocket
连接的当前状态。
值
一个数字,是 WebSocket
接口定义的四个可能状态常量之一:
WebSocket.CONNECTING
(0)-
套接字已创建,但连接尚未打开。
WebSocket.OPEN
(1)-
连接已打开,准备进行通信。
WebSocket.CLOSING
(2)-
连接正在关闭中。
WebSocket.CLOSED
(3)-
连接已关闭或无法打开。
规范
Specification |
---|
WebSockets # ref-for-dom-websocket-readystate① |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
readyState |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.