このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

BroadcastChannel()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2022年3月⁩.

BroadcastChannel() コンストラクターは、新しい BroadcastChannel を作成し、それを基礎となるチャンネルに接続します。

メモ: この機能はウェブワーカー内で利用可能です。

構文

js
new BroadcastChannel(channelName)

channelName

文字列で、チャンネルの名前を表します。 同じオリジンを持つすべての閲覧コンテキストに対して、この名前を持つ単一のチャンネルがあります。

js
// "internal_notification" チャンネルをリッスンする新しいチャンネルを作成します。

const bc = new BroadcastChannel("internal_notification");
bc.postMessage("New listening connected!");

仕様書

Specification
HTML
# dom-broadcastchannel-dev

ブラウザーの互換性

関連情報