BroadcastChannel.postMessage()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2022.

BroadcastChannel.postMessage() は、任意の種類の Object のメッセージを、同じオリジンを持つ任意の閲覧コンテキスト内の各リスナーに送信します。 メッセージは、チャンネルに結び付けられた各 BroadcastChannel を対象とした 'message' イベントとして送信します。

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

構文

js
channel.postMessage(message)

引数

message

他のウィンドウに送信するデータ。データは構造化複製アルゴリズムを使用してシリアライズされます。 つまり、様々なデータオブジェクトを自分でシリアライズすることなく、安全に出力先のウィンドウに渡すことができます。

返値

なし。

仕様書

Specification
HTML
# dom-broadcastchannel-postmessage-dev

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
postMessage

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
User must explicitly enable this feature.

関連情報