BroadcastChannel:name 属性
注意:此功能在 Web Workers 中可用。
name 是 BroadcastChannel 接口的一个只读属性,它返回一个字符串,该字符串通过其名称唯一标识给定的频道。此名称在创建时传递给 BroadcastChannel() 构造函数,因此是只读的。
值
字符串。
示例
js
// Connect to a channel
const bc = new BroadcastChannel("test_channel");
// More operations (like postMessage, …)
// Log the channel name to the console
console.log(bc.name); // "test_channel"
// When done, disconnect from the channel
bc.close();
规范
| 规范 |
|---|
| HTML # dom-broadcastchannel-name-dev |
浏览器兼容性
加载中…
另见
BroadcastChannel,它所属的接口。