Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// In Tab 1 — send message const channel = new BroadcastChannel("app-sync"); channel.postMessage({ type: "logout" }); // In Tab 2 — receive message const channel2 = new BroadcastChannel("app-sync"); channel2.onmessage = function(e) { if (e.data.type === "logout") { location.href = "/login"; } }; // Clean up when done channel.close();
Result
Open