title | short-title | slug | page-type | browser-compat |
---|---|---|---|---|
CloseEvent: CloseEvent() constructor |
CloseEvent() |
Web/API/CloseEvent/CloseEvent |
web-api-constructor |
api.CloseEvent.CloseEvent |
{{APIRef("Websockets API")}}
The CloseEvent()
constructor creates a new {{domxref("CloseEvent")}} object.
new CloseEvent(type)
new CloseEvent(type, options)
type
- : A string with the name of the event.
It is case-sensitive and browsers always set it to
close
.
- : A string with the name of the event.
It is case-sensitive and browsers always set it to
options
{{optional_inline}}- : An object that, in addition of the properties defined in {{domxref("Event/Event", "Event()")}}, has the following properties:
wasClean
{{optional_inline}}- : A boolean value indicating if the connection has been closed cleanly or not. It defaults to
false
.
- : A boolean value indicating if the connection has been closed cleanly or not. It defaults to
code
{{optional_inline}}- : An integer representing the connection close code sent by the server. It defaults to
0
.
- : An integer representing the connection close code sent by the server. It defaults to
reason
{{optional_inline}}- : A string containing a human-readable reason describing why the server closed the connection. It defaults to
''
- : A string containing a human-readable reason describing why the server closed the connection. It defaults to
- : An object that, in addition of the properties defined in {{domxref("Event/Event", "Event()")}}, has the following properties:
A new {{domxref("CloseEvent")}} object.
{{Specifications}}
{{Compat}}
- {{domxref("CloseEvent")}}, the interface of the objects it constructs.