dispatchEvent method
Sends an event to the current element.
![]() ![]() |
Syntax
object.dispatchEvent(evt, pfResult)Parameters
- evt [in]
-
Type: IDOMEvent
The event object to dispatch.
- pfResult [out, retval]
-
Type: Boolean
A Boolean value that indicates whether any of the event handlers called preventDefault.
Return value
Type: Boolean
A Boolean value that indicates whether any of the event handlers called preventDefault.
trueDefault. The default action is permitted.
falseThe caller should prevent the default action.
Standards information
Remarks
Events that the dispatchEvent method dispatches are subject to the same capturing and bubbling behavior as events that the browser dispatches.
You cannot cancel some events. For more information, see the documentation for the event.
In general, events can only be dispatched from elements that are part of the document object model, per the HTML5 specification.
var a = document.createElement('a'); var evt = document.createEvent('MouseEvents'); evt.initEvent("click", true, true); a.dispatchEvent(evt);
For interoperability purposes, however, Internet Explorer for Windows Phone 8.1 Update allows events to be triggered by elements that are not part of the document object model. For best results, dynamically created elements should be added to the document object model.
See also
- window
- ApplicationCache
- AudioTrackList
- CryptoOperation
- document
- IDBDatabase
- IDBRequest
- IDBTransaction
- KeyOperation
- MediaSource
- MessagePort
- Node
- Screen
- SourceBuffer
- SourceBufferList
- SVGElementInstance
- TextNode
- TextTrack
- TextTrackCue
- TextTrackList
- WebSocket
- Window
- Window
- WorkerGlobalScope
- XMLHttpRequest
- Reference
- addEventListener
- createEvent
- initEvent

