CloseEvent() 构造函数创建新 CloseEvent .

句法

var event = new CloseEvent(typeArg, closeEventInit);
					

typeArg
DOMString 表示事件的名称。
closeEventInit 可选
CloseEventInit 字典,拥有以下字段:
  • "wasClean" , optional and defaulting to false , of type long , indicates if the connection has been closed cleanly or not.
  • "code" , optional and defaulting to 0 , of type unsigned short , that is the connection close code sent by the server.
  • "reason" , optional and defaulting to '' , of type DOMString , that is a human-readable reason why the server closed the connection.

CloseEventInit 字典还接受字段来自 EventInit 字典。

规范

规范 状态 注释
HTML 实时标准
The definition of 'CloseEvent()' in that specification.
实时标准 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
CloseEvent() 构造函数 Chrome ? Edge ? Firefox 8 IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Firefox Android 8 Opera Android ? Safari iOS ? Samsung Internet Android ?

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改:
  1. Websockets API
  2. CloseEvent
  3. 构造函数
    1. CloseEvent()
  4. 继承:
    1. 事件
  5. Related pages for Websockets API
    1. MessageEvent
    2. WebSocket