The WebSocket.close()
method closes the WebSocket
connection or connection attempt, if any. If the connection is already CLOSED
, this method does nothing.
WebSocket.close();
code
Optional
CloseEvent
for permitted values.reason
Optional
INVALID_ACCESS_ERR
code
was specified.SYNTAX_ERR
reason
string is too long or contains unpaired surrogates.Note: In Gecko, this method didn't support any parameters prior to Gecko 8.0 (Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5).
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'WebSocket.close()' in that specification. | Living Standard | Initial definition |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | ? | 8
|
? | Yes | ? |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | ? | Yes | ? | Yes | ? | ? | ? |
© 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/close