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
可选
CloseEvent
for permitted values.
reason
可选
INVALID_ACCESS_ERR
code
was specified.
SYNTAX_ERR
reason
string is too long or contains unpaired surrogates.
注意: In Gecko, this method didn't support any parameters prior to Gecko 8.0 (Firefox 8.0 / Thunderbird 8.0 / SeaMonkey 2.5).
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of 'WebSocket.close()' in that specification. |
实时标准 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
close
|
Chrome 4 | Edge 12 |
Firefox
8
|
IE 10 | Opera 12.1 | Safari 5 | WebView Android ≤37 | Chrome Android 18 |
Firefox Android
8
|
Opera Android 12.1 | Safari iOS 4.2 | Samsung Internet Android 1.0 |
完整支持
见实现注意事项。