EventTarget: dispatchEvent() method - Web APIs | MDN

Syntax

Parameters

event

The Event object to dispatch. Its Event.target property will be set to the current EventTarget.

Return value

false if event is cancelable, and at least one of the event handlers which received event called Event.preventDefault(). Otherwise true.

Exceptions

InvalidStateError DomException

Thrown if the event's type was not specified during event initialization.

Warning: Exceptions thrown by event handlers are reported as uncaught exceptions. The event handlers run on a nested callstack; they block the caller until they complete, but exceptions do not propagate to the caller.

Example

See Creating and dispatching events.

Specifications

Specification
DOM
# ref-for-dom-eventtarget-dispatcheventâ‘¢

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.