The Event() constructor creates a new Event.

Syntax

 event = new Event(typeArg, eventInit);

Values

typeArg
This is a DOMString representing the name of the event.
eventInit Optional
This is an EventInit dictionary, having the following fields:
  • bubbles: (optional) a Boolean indicating whether the event bubbles. The default is false.
  • cancelable: (optional) a Boolean indicating whether the event can be cancelled. The default is false.
  • composed: (optional) a Boolean indicating whether the event will trigger listeners outside of a shadow root (see Event.composed for more details). The default is false.

Example

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

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

// event can be dispatched from any element, not only the document
myDiv.dispatchEvent(evt);

Specifications

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

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support 15Edge Full support YesFirefox Full support 11IE No support NoOpera Full support 11.6Safari Full support 6WebView Android Full support YesChrome Android Full support 18Edge Mobile Full support YesFirefox Android Full support 14Opera Android Full support 11.6Safari iOS Full support 6Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also

Document Tags and Contributors

Last updated by: sideshowbarker,