BroadcastChannel:postMessage() 方法
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2022.
备注: 此特性在 Web Worker 中可用。
BroadcastChannel
接口的 postMessage()
方法向任何浏览上下文中具有相同的源的每个侦听器发送一条消息,该消息可以是任何类型的 Object
。该消息以 message
事件的形式传输,该事件针对绑定到频道的每个 BroadcastChannel
。
语法
js
postMessage(message)
参数
返回值
无。
异常
InvalidStateError
DOMException
-
如果
BroadcastChannel
已关闭,则抛出此异常。 DataCloneError
DOMException
-
如果输入数据的任何部分不可序列化,则抛出此异常。
规范
Specification |
---|
HTML # dom-broadcastchannel-postmessage-dev |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
postMessage |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- User must explicitly enable this feature.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
参见
- 所属接口:
BroadcastChannel