7

HTML5 BroadcastChannel API is a great solution to sending data between tabs/windows.

They are opened with new BroadcastChannel(name) and closed by calling the .close() function.

However, it provides no explanation on how to view existing opened BroadcastChannels. If I'm creating BroadcastChannels dynamically (not with a fixed channel name), viewing the BroadcastChannels currently opened is highly useful.

A search on Google ("view existing broadcast channels javascript") and viewing the top three results (1, 2, 3) all provide no pointers as to how to view all opened broadcast channels.

I've tried viewing the BroadcastChannel interface but it does not provide any .listOpenedChannels() function or anything of the sort.

How do I view existing opened BroadcastChannels?

JMP
  • 4,417
  • 17
  • 30
  • 41
CaptainA33
  • 71
  • 3
  • You could use localStorage so that you add the dynamic name on a well known named property there. But... why use a dynamic name to begin with? (Also, such a method on the official API would allow any third party script to hijack any such channels, which is not something we want). – Kaiido May 19 '21 at 23:42
  • Hey, I was wondering how you create the listening channels dynamically. Opening the channels with unique names on the sender is easy but how the listener channels will be created that will use that unique name to get their messages? – Cagri Aug 29 '22 at 19:05

0 Answers0