W3cubDocs

/Web APIs

ExtendableMessageEvent: ExtendableMessageEvent() constructor

The ExtendableMessageEvent() constructor creates a new ExtendableMessageEvent object.

Syntax

js

new ExtendableMessageEvent(type)
new ExtendableMessageEvent(type, options)

Parameters

type

A string with the name of the event. It is case-sensitive and browsers set it to messageerror or message.

options Optional

An object that, in addition of the properties defined in ExtendableEvent(), can have the following properties:

data Optional

The event's data; this can be any data type. It defaults to null.

origin Optional

A string that defines the origin of the corresponding service worker's environment settings object. It defaults to "".

lastEventId Optional

A string that defines the last event ID of the event source. It defaults to "".

source Optional

The Client, ServiceWorker or MessagePort that sent the message. It defaults to null.

ports Optional

An array containing the MessagePort objects connected to the channel sending the message. It defaults to an empty array.

Return value

Examples

js

const options = {
  data: "hello message",
  source: MessagePortReference,
  ports: MessagePortListReference,
};

const myEME = new ExtendableMessageEvent("message", init);

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
ExtendableMessageEvent 51 17 44 No 38 11.1 51 51 44 41 11.3 5.0

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ExtendableMessageEvent/ExtendableMessageEvent