CloseEvent
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
備註: 此功能可在 Web Worker 中使用。
當連線關閉時,WebSocket 會傳送一個 CloseEvent 給用戶端。這個事件會傳遞給 WebSocket 物件的 onclose 屬性所指定的監聽器。
建構子
CloseEvent()-
建立一個新的
CloseEvent。
實例屬性
此介面也繼承自其父介面 Event 的屬性。
CloseEvent.codeRead only-
回傳一個包含關閉碼的
unsigned short。 CloseEvent.reasonRead only-
回傳一個字串,指出伺服器關閉連線的原因。這個原因依據特定伺服器與子協議而有所不同。
CloseEvent.wasCleanRead only-
回傳一個布林值,指出連線是否乾淨地關閉。
實例方法
此介面也繼承自其父介面 Event 的方法。
規範
| Specification |
|---|
| WebSockets> # the-closeevent-interface> |
瀏覽器相容性
Loading…