BroadcastChannel.postMessage()

可以使用 BroadcastChannel.postMessage() 发送一条任意 Object 类型的消息,给所有同下监听了该频道的所有浏览器上下文。消息以 message 事件的形式发送给每一个绑定到该频道的广播频道。

Note: 此特性在 Web Worker 中可用。

语法

var str = channel.postMessage(object);

规范

规范 状态 备注
HTML Living Standard
BroadcastChannel.postmessage()
Living Standard Initial definition.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
postMessageChrome Full support 54Edge ? Firefox Full support 38IE No support NoOpera Full support 41Safari No support NoWebView Android Full support 54Chrome Android Full support 54Firefox Android ? Opera Android Full support 41Safari iOS No support NoSamsung Internet Android Full support 6.0

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

另见