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,它所屬的介面。