BroadcastChannel()
BroadcastChannel() 构造函数用于创建一个 BroadcastChannel 对象,并与底层的通道相关联。
备注: 此特性在 Web Worker 中可用
语法
js
new BroadcastChannel(channelName)
参数
示例
js
// 创建一个监听“internal_notification”通道的新通道。
const bc = new BroadcastChannel("internal_notification");
bc.postMessage("New listening connected!");
规范
| Specification | 
|---|
| HTML Standard  # dom-broadcastchannel-dev  | 
浏览器兼容性
BCD tables only load in the browser
另见
- 所属接口:
BroadcastChannel