Javascript examples for Language Basics:BroadcastChannel
Create BroadcastChannel and post and receive message
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from ww w. j av a 2 s . co m var broadcaster = new BroadcastChannel('Consumer'); var messageReceiver= new BroadcastChannel('Consumer'); messageReceiver.onmessage = function(event) { console.log(event.data); } broadcaster.postMessage("hello"); } </script> </head> <body> </body> </html>