BroadcastChannel: BroadcastChannel() コンストラクター
Baseline
広く利用可能
この機能は広く実装されており、多くのバージョンの端末やブラウザーで動作します。2022年3月以降、すべてのブラウザーで利用可能です。
メモ: この機能はウェブワーカー内で利用可能です。
BroadcastChannel() コンストラクターは、新しい BroadcastChannel を作成し、それを基礎となるチャンネルに接続します。
構文
js
new BroadcastChannel(channelName)
値
channelName-
文字列で、チャンネルの名前を表します。 同じオリジンを持つすべての閲覧コンテキストに対して、この名前を持つ単一のチャンネルがあります。
例
js
// "internal_notification" チャンネルをリッスンする新しいチャンネルを作成します。
const bc = new BroadcastChannel("internal_notification");
bc.postMessage("New listening connected!");
仕様書
| 仕様書 |
|---|
| HTML> # dom-broadcastchannel-dev> |
ブラウザーの互換性
関連情報
BroadcastChannel: 所属するインターフェイス。