Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

Event()

The Event() constructor creates a new Event.

Syntax

 event = new Event(typeArg, eventInit);

Values

typeArg
Is a DOMString representing the name of the event.
eventInitOptional
Is an EventInit dictionary, having the following fields:
  • "bubbles", optional and defaulting to false, of type Boolean, indicating if the event bubbles or not.
  • "cancelable", optional and defaulting to false, of type Boolean, indicating if the event can be canceled or not.

Example

// create a look event that bubbles up and cannot be canceled

var ev = new Event("look", {"bubbles":true, "cancelable":false});
document.dispatchEvent(ev);

Specifications

Specification Status Comment
DOM
The definition of 'Event()' in that specification.
Living Standard Initial definition.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
BasicSupport 15 11 (11) Not supported 11.60 Nightly build (535.2)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? 11.0 (11) ? ? ?

See also

Document Tags and Contributors

 Contributors to this page: Dattaya, romko391, fscholz, teoli
 Last updated by: Dattaya,