This page was translated from English by the community. Learn more and join the MDN Web Docs community.

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을 생성하고 이를 채널에 연결합니다.

참고 : 이 기능은 Web Worker에서 사용할 수 있습니다.

구문

js
new BroadcastChannel(channelName)

매개변수

channelName

채널의 이름을 나타내는 문자열로, 출처가 동일한 모든 브라우징 맥락들에 대해 이 이름을 가진 채널이 단 하나만 존재합니다.

예제

js
// "internal_notification" 채널을 수신하는 새 채널을 만듭니다.

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

명세서

Specification
HTML
# dom-broadcastchannel-dev

브라우저 호환성

같이 보기