WebSocket()
constructor returns a new
WebSocket
对象。
var aWebSocket = new WebSocket(url [, protocols]);
url
The URL to which to connect; this should be the URL to which the WebSocket server will respond.
protocols
可选
协议
). If you don't specify a protocol string, an empty string is assumed.
SECURITY_ERR
The port to which the connection is being attempted is being blocked.
The URL is invalid.
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of 'the WebSocket constructor' in that specification. |
实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
WebSocket()
构造函数
|
Chrome Yes | Edge ≤79 |
Firefox
7
|
IE ? | Opera Yes | Safari ? | WebView Android Yes | Chrome Android Yes | Firefox Android 7 | Opera Android ? | Safari iOS ? | Samsung Internet Android Yes |
完整支持
兼容性未知
见实现注意事项。
WebSocket
WebSocket()