我们的志愿者还没有将这篇文章翻译为 中文 (简体)。加入我们帮助完成翻译!
您也可以阅读此文章的English (US)版。
The CloseEvent()
constructor creates a new CloseEvent
.
Syntax
event = new CloseEvent(typeArg, closeEventInit);
Values
- typeArg
- Is a
DOMString
representing the name of the event. - closeEventInitOptional
- Is a
CloseEventInit
dictionary, having the following fields:"wasClean"
, optional and defaulting tofalse
, of typelong
, indicates if the connection has been closed cleanly or not."code"
, optional and defaulting to0
, of typeunsigned short
, that is the connection close code sent by the server."reason"
, optional and defaulting to''
, of typeDOMString
, that is a human-readable reason why the server closed the connection.
The
CloseEventInit
dictionary also accepts fields from theEventInit
dictionary.
Specifications
Specification | Status | Comment |
---|---|---|
WHATWG HTML Living Standard The definition of 'CloseEvent()' in that specification. |
Living Standard | Initial definition. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | ? | 8 (8) | ? | ? | ? |
Support in Web workers | ? | (Yes) | ? | ? | ? |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | ? | ? | 8.0 (8) | ? | ? | ? |
Support in Web workers | ? | ? | (Yes) | ? | ? | ? |
See also
CloseEvent
, the interface of the objects it constructs.