1. 9 Communication
    1. 9.1 The MessageEvent interface

9 Communication

The WebSocket interface used to be defined here. It is now defined in WebSockets. [WEBSOCKETS]

9.1 The MessageEvent interface

MessageEvent

Support in all current engines.

Firefox3+Safari4+Chrome1+
Opera10.6+Edge79+
Edge (Legacy)12+Internet Explorer9+
Firefox Android4+Safari iOS3.2+Chrome Android18+WebView Android37+Samsung Internet1.0+Opera Android11+

Messages in server-sent events, cross-document messaging, channel messaging, broadcast channels, and WebSockets use the MessageEvent interface for their message events: [WEBSOCKETS]

event.data

Returns the data of the message.

event.origin

Returns the origin of the message, for server-sent events and cross-document messaging.

event.lastEventId

Returns the last event ID string, for server-sent events.

event.source

Returns the WindowProxy of the source window, for cross-document messaging, and the MessagePort being attached, in the connect event fired at SharedWorkerGlobalScope objects.

event.ports

Returns the MessagePort array sent with the message, for cross-document messaging and channel messaging.

Various APIs (e.g., WebSocket, EventSource) use the MessageEvent interface for their message event without using the MessagePort API.