W3cubDocs

/DOM Events

message (WebSocket)

A message event informs the target, a WebSocket, RTCDataConnection or a BroadcastChannel object, that a message has been received.

If the target is a RTCDataConnection, an event handler for this event can be added via the RTCDataConnection.onmessage property.

If the target is a BroadcastChannel, an event handler for this event can be added via the BroadcastChannel.onmessage property.

General info

Interface
MessageEvent
Bubbles
No
Cancelable
No
Target
RTCDataChannelEvent, WebSocket, BroadcastChannel
Default Action
None

Properties

A MessageEvent being an Event, this event also implements these properties.

data Read only
Is a DOMString containing the message received.

Methods

A MessageEvent being an Event, this event also implements these properties.

Specifications

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) No support (Yes) ?
on BroadcastChannel No support No support 38 (38) No support No support No support
Feature Android Chrome for Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? (Yes) ? No support ? ?
on BroadcastChannel No support No support No support 38.0 (38) No support No support No support

See also

  • WebRTC
  • BroadcastChannel API
  • WebSockets

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/Events/message