We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE


This page is not complete.

The MessageEvent() constructor creates a new MessageEvent object instance.


var messageEvent = new MessageEvent(type, init);


The type of MessageEvent that will be created. This can be one of XXX

init Optional

A dictionary object that can contain the following properties:

  • data: The data you want contained in the MessageEvent. This can be of any data type, and will default to null if not specified.
  • origin: A USVString representing the origin of the message emitter. This defaults to an empty string ("") if not specified.
  • lastEventId: A DOMString representing a unique ID for the event. This defaults to an empty string ("") if not specified.
  • source: An MessageEventSource (which can be a WindowProxy, MessagePort, or ServiceWorker object) representing the message emitter. This defaults to null if not set.
  • ports: An array of MessagePort objects representing the ports associated with the channel the message is being sent through (where appropriate, e.g. in channel messaging or when sending a message to a shared worker). This defaults to an empty array ([]) if not specified.


var myMessage = new MessageEvent('worker', {
  data : 'hello'


Specification Status Comment
The definition of 'MessageEvent' in that specification.
Unknown Initial definition

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1 (Yes) 4.0 (2.0) 9 ? 10.0+
origin as USVString and source as MessageEventSource (Yes) ? 55.0 (55.0) No support ? ?
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? (Yes) ? ? ? 3.0+
origin as USVString and source as MessageEventSource ? ? 55.0 (55.0) No support ? ?

See also

  • ExtendableMessageEvent — similar to this interface but used in interfaces that needs to give more flexibility to authors.

Document Tags and Contributors

 Contributors to this page: chrisdavidmills
 Last updated by: chrisdavidmills,