Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 1.31 KB

File metadata and controls

48 lines (34 loc) · 1.31 KB
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.

Syntax

new CloseEvent(type)
new CloseEvent(type, options)

Parameters

  • type
    • : A string with the name of the event. It is case-sensitive and browsers always set it to close.
  • 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.
      • code {{optional_inline}}
        • : An integer representing the connection close code sent by the server. It defaults to 0.
      • reason {{optional_inline}}
        • : A string containing a human-readable reason describing why the server closed the connection. It defaults to ''

Return value

A new {{domxref("CloseEvent")}} object.

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{domxref("CloseEvent")}}, the interface of the objects it constructs.