BroadcastChannel()

Baseline 2022

Newly available

Since March 2022, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

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 Standard
# dom-broadcastchannel-dev

브라우저 호환성

BCD tables only load in the browser

같이 보기