Edition for Web Developers — Last Updated 16 January 2024
The WebSocket interface used
to be defined here. It is now defined in WebSockets. [WEBSOCKETS]
MessageEvent interfaceSupport in all current engines.
Messages in server-sent events, cross-document messaging,
channel messaging, broadcast channels, and WebSockets use
the MessageEvent interface for their message
events: [WEBSOCKETS]
event.dataReturns the data of the message.
event.originReturns the origin of the message, for server-sent events and cross-document messaging.
event.lastEventIdReturns the last event ID string, for server-sent events.
event.sourceReturns the WindowProxy of the source window, for cross-document
messaging, and the MessagePort being attached, in the connect event fired at
SharedWorkerGlobalScope objects.
event.portsReturns 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.