BroadcastChannel.close()

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.close() は、基礎となるチャンネルへの接続を終了し、オブジェクトをガベージコレクションできるようにします。 このチャンネルがもう必要ないことをブラウザーが知る他の方法はないので、これは実行するのに必要なステップです。

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

構文

js
channel.close()

js
// チャンネルに接続
const bc = new BroadcastChannel("test_channel");

// その他の操作(postMessage など)

// 終了したら、チャンネルから切断します
bc.close();

仕様書

Specification
HTML
# dom-broadcastchannel-close-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
close

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.

関連情報