initCloseEvent method

Initializes the close event.

Important  As of Microsoft Edge, the createEvent()/initEvent() constructor pattern for synthetic events is deprecated. See the Synthetic Events page for more information.
Internet Explorer 10



var retval = CloseEvent.initCloseEvent(typeArg, canBubbleArg, cancelableArg, wasCleanArg, codeArg, reasonArg);


typeArg [in]

Type: DOMString

The type of the event being created.

canBubbleArg [in]

Type: boolean

Indicates whether the event can bubble. When true the event should propagate upward. When false the event does not propagate upward.

cancelableArg [in]

Type: boolean

Indicates whether the event’s default action can be prevented. When true, the default action can be canceled. When false, the default action cannot be canceled.

wasCleanArg [in]

Type: boolean

Represents whether the connection closed cleanly or not.

codeArg [in]

Type: unsigned long

Represents the WebSocket connection close code provided by the server.

reasonArg [in]

Type: DOMString

Represents the WebSocket connection close reason provided by the server.

Return value


This method can return one of these values.



Initializes the event in a manner analogous to the similarly-named method in the DOM events.

See also