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) aBoolean
indicating whether the event bubbles. The default isfalse
."cancelable"
: (optional) aBoolean
indicating whether the event can be cancelled. The default isfalse
."composed"
: (optional) aBoolean
indicating whether the event will trigger listeners outside of a shadow root. The default isfalse
.
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
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
BasicSupport | 15.0 | 11 (11) | No support | 11.60 | Nightly build (535.2) |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|
Basic support | ? | (Yes) | 11.0 (11) | ? | ? | ? | (Yes) |
See also
Document Tags and Contributors
Tags:
Contributors to this page:
RayannTedds,
matthax,
mayank23,
Speich,
DomenicDenicola,
jpmedley,
svincent,
Dattaya,
romko391,
fscholz,
teoli
Last updated by:
RayannTedds,