This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Note: This feature is available in Web Workers.
The CustomEvent interface can be used to attach custom data to an event generated by an application.
As an alternative to CustomEvent, you can subclass the Event interface to add custom data and behavior.
Note: If used to attempt to communicate between a web extension content script and a web page script, a non-string detail property throws with "Permission denied to access property" in Firefox. To avoid this issue clone the object. See Share objects with page scripts for more information.
CustomEvent()Creates a new CustomEvent.
This interface inherits properties from its parent, Event.
CustomEvent.detail Read only
Returns any data passed when initializing the event.
This interface inherits methods from its parent, Event.
CustomEvent.initCustomEvent() Deprecated
Initializes a CustomEvent object. If the event has already been dispatched, this method does nothing.
| Specification |
|---|
| DOM> # interface-customevent> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
CustomEvent |
15 | 12 | 11 | 11.6 | 6 | 18 | 14 | 12 | 6 | 1.0 | 4.4 | 6 |
CustomEvent |
5 | 12 | 6 | 11 | 5 | 18 | 6 | 11 | 5 | 1.0 | 3 | 5 |
detail |
5 | 12 | 6 | 11.6 | 5 | 18 | 6 | 12 | 5 | 1.0 | 3 | 5 |
initCustomEvent |
5 | 12 | 6 | 11 | 5 | 18 | 6 | 11 | 5 | 7.0 | 3 | 5 |
worker_support |
43 | 17 | 48 | 30 | 12 | 43 | 48 | 30 | 12 | 4.0 | 43 | 12 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent