The Event() constructor creates a new Event.
event = new Event(typeArg, eventInit);
DOMString representing the name of the event.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.// 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);
| Specification | Status | Comment |
|---|---|---|
| DOM The definition of 'Event()' in that specification. | Living Standard | Initial definition |
| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | 15 | Yes | 11 | No | 11.6 | 6 |
| Mobile | |||||||
|---|---|---|---|---|---|---|---|
| Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
| Basic support | Yes | 18 | Yes | 14 | 11.6 | 6 | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Event/Event