CloseEvent()
The CloseEvent()
constructor creates a new CloseEvent
.
Syntax
new CloseEvent(typeArg); new CloseEvent(typeArg, closeEventInit);
Values
typeArg
-
Is a
DOMString
representing the name of the event. -
closeEventInit
Optional -
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.
Note: The
CloseEventInit
dictionary also accepts fields from theEventInit
dictionary. -
Specifications
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
CloseEvent |
16 |
14 |
8 |
No |
? |
6 |
≤37 |
18 |
8 |
? |
6 |
1.0 |
See also
-
CloseEvent
, the interface of the objects it constructs.
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/CloseEvent