event.initEvent

The initEvent method is deprecated. Use event constructors instead.

Summary

The initEvent method is used to initialize the value of an event created using document.createEvent.

Syntax

event.initEvent(type, bubbles, cancelable);
type
The type of event.
bubbles
A boolean indicating whether the event should bubble up through the event chain or not (see bubbles).
cancelable;
A boolean indicating whether the event can be canceled (see cancelable).

Example

// create a click event that bubbles up and 
// cannot be canceled 
event.initEvent("click", true, false);

The page on dispatchEvent has a more useful example.

Notes

Events initialized in this way must have been created with the document.createEvent method. initEvent must be called to set the event before it is dispatchEvent.

Specification

Document Tags and Contributors

Last updated by: kscarfone,