The WebSocket()
constructor returns a new WebSocket
object.
var ws = new WebSocket("ws://localhost:8080");
url
protocols
Optional
protocol
). If you don't specify a protocol string, an empty string is assumed.SECURITY_ERR
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'the WebSocket constructor' in that specification. | Living Standard |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | ? | 7
|
? | Yes | ? |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | ? | Yes | ? | 7 | ? | ? | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket