EventTarget.dispatchEvent(event) sends an Event to that target and runs matching listeners right away (synchronously). Per MDN, create and initialize the event first — dispatch is the last step to fire it.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call target.dispatchEvent. Start with this line.
JavaScript
target.dispatchEvent(event)
Call
What it does
target.dispatchEvent(event)
Primary signature.
target.dispatchEvent(...)
Call with the arguments your case needs.
Built into the browser. Call dispatchEvent(...) on an EventTarget (or Element, Document, Window, …) — no import required.
Library declarations
JavaScript
target.dispatchEvent(event)
Parameters
Parameter
Description
event
Required. Event / CustomEvent with a type
cancelable
Optional. Set { cancelable: true } so preventDefault can cancel
detail
Optional. Payload on CustomEvent
Return Value
Return Value
Description
*
false if canceled; else true
JavaScript Examples
Example 1 — Basic dispatchEvent()
Create a target, listen, then fire a simple event.
JavaScript
const target = new EventTarget();
target.addEventListener("hello", () => {
console.log("Hello from dispatchEvent");
});
target.dispatchEvent(new Event("hello"));
type: probe
isTrusted: false
target is EventTarget: true
How It Works
Dispatch a probe. Same API as a real event type string.
Read isTrusted. Always false for dispatchEvent.
Check target. Set to the object you called dispatchEvent on.
Security note. Do not treat synthetic events as user gestures.
Compatibility
Browser Support
EventTarget.dispatchEvent() is marked Baseline Widely available on MDN (since July 2015). It is a browser Web API (also available in Web Workers).
✓ Baseline · Widely available
EventTarget.dispatchEvent()
Supported across modern Chrome, Firefox, Safari, and Edge for firing synthetic events.
98%Browser support
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
dispatchEvent()Excellent
Bottom line: Safe for production. Create Event/CustomEvent first, then dispatch; check the boolean return when the event is cancelable.
Frequently Asked Questions
It sends an Event to that target and runs matching listeners immediately (synchronously). Create the event first with new Event() or new CustomEvent().
No. MDN marks EventTarget.dispatchEvent() as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard. It is also available in Web Workers.
Yes. Unlike most native browser events that are queued, dispatchEvent runs applicable listeners before it returns. Code after dispatchEvent runs only after those listeners finish.
It returns false if the event is cancelable and a listener called preventDefault(). Otherwise it returns true.
Native browser events have isTrusted true. Events you fire with dispatchEvent have isTrusted false — they are synthetic.
Yes. When you call dispatchEvent, Event.target is initialized to the EventTarget you called it on.