Event()
The Event()
constructor creates a new Event
.
Syntax
JavaScript
Copy Code
event = new Event(typeArg, eventInit);
Values
- typeArg
- Is a
DOMString
representing the name of the event. - eventInit Optional
- 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 canceled. The default isfalse
."scoped"
: (Optional) ABoolean
indicating whether the given event bubbles. If this value istrue
,deepPath
will only contain a target node.
Example
JavaScript
Copy Code
// 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) | No support | 11.60 | Nightly build (535.2) |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | ? | 11.0 (11) | ? | ? | ? |
See also
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/event/event