1

I have a website with a serviceWorker push event, and then a postMessage which sends back data. When this data is received, I open a window using window.open, but if I have like 3 tabs opened, the window is opened 3 times.

I put a specific name in window.open, I even tried setting a cookie just before window.open, and then when the cookie value is 1, window.open should not be triggered.

However it does not work, I guess because window.open is called for each tab at the same time so the cookie does not exists, and technically the window name does not exist either.

I'm stuck, if anyone has an idea... Thanks a lot

Agnes D
  • 431
  • 2
  • 12
  • Have you tried using `BroadcastChannel`, the Tab you want to listen to messages could then be the only one that subscribes to this Channel. https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API – Keith Nov 23 '22 at 14:11

0 Answers0