The CloseEvent() constructor creates a new CloseEvent.
Syntax
var event = new CloseEvent(typeArg, closeEventInit);
Values
typeArg- Is a
DOMStringrepresenting the name of the event. closeEventInitOptional
- Is a
CloseEventInitdictionary, 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
CloseEventInitdictionary also accepts fields from theEventInitdictionary.
Specifications
| Specification | Status | Comment |
|---|---|---|
| HTML Living Standard The definition of 'CloseEvent()' in that specification. |
Living Standard | Initial definition. |
Browser compatibility
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.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
CloseEvent() constructor | Chrome ? | Edge ? | Firefox Full support 8 | IE ? | Opera ? | Safari ? | WebView Android ? | Chrome Android ? | Firefox Android Full support 8 | Opera Android ? | Safari iOS ? | Samsung Internet Android ? |
Legend
- Full support
- Full support
- Compatibility unknown
- Compatibility unknown
See also
CloseEvent, the interface of the objects it constructs.
