WebSocket.readyState read-only property returns the current state of the WebSocket 连接。

句法

var readyState = aWebSocket.readyState;
					

One of the following unsigned short 值:

状态 描述
0 CONNECTING Socket has been created. The connection is not yet open.
1 OPEN The connection is open and ready to communicate.
2 CLOSING The connection is in the process of closing.
3 CLOSED The connection is closed or couldn't be opened.

规范

规范 状态 注释
HTML 实时标准
The definition of 'WebSocket: readyState' in that specification.
实时标准 初始定义

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
readyState Chrome 43 Edge 12 Firefox 19 IE 10 Opera 30 Safari 10 WebView Android 43 Chrome Android 43 Firefox Android 19 Opera Android 30 Safari iOS 10 Samsung Internet Android 4.0

图例

完整支持

完整支持

元数据

  • 最后修改: