BroadcastChannel()
构建函数用于创建一个 BroadcastChannel
对象,并与对应的频道相关联。
Note: 此特性在 Web Worker 中可用。
语法
channel = new BroadcastChannel(channel);
值
示例
// create a new channel listening to the "internal_notification" channel.
var bc = new BroadcastChannel('internal_notification');
bc.postMessage('New listening connected!');
规范
规范 | 示例 | 备注 |
---|---|---|
HTML Living Standard BroadcastChannel() |
Living Standard | Initial definition. |
浏览器兼容性
BCD tables only load in the browser
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