MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-survey

这篇翻译不完整。请帮忙从英语翻译这篇文章

An 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.

一般信息

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

特性

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

data 只读
Is a DOMString containing the message received.

方法

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

相关事件

提示

Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browsers
message on RTCDataChannel
Candidate Recommendation Adds RTCDataChannel as an EventTarget and defines when this event is sent.
HTML Living Standard
message on BroadcastChannel
Living Standard Adds BroadcastChannel as an EventTarget and defines when this event is sent.

浏览器兼容性

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 (Yes) (Yes) (Yes) 未实现 (Yes) ?
on BroadcastChannel 未实现 未实现 38 (38) 未实现 未实现 未实现
  
Feature Android Chrome for Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? (Yes) ? 未实现 ? ?
on BroadcastChannel  未实现 未实现 未实现 38.0 (38) 未实现 未实现 未实现

看其他

  • WebRTC
  • BroadcastChannel API
  • WebSockets

文档标签和贡献者

 此页面的贡献者: Yongest, hellowrenfei
 最后编辑者: Yongest,