// Connection to a broadcast channel
const bc = new BroadcastChannel("test_channel");Broadcast Channel API / notebook
Broadcast Channel API
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
// Example of sending of a very simple message
bc.postMessage("This is a test message.");// A handler that only logs the event to the console:
bc.onmessage = (event) => {
console.log(event);
};// Disconnect the channel
bc.close();