I have 2 applications where App2 is accessible when we click on a link in App1. Each time this link is clicked, a new browser tab is opened containing App2.
Now I have a requirement where upon logout of App1, all the instances (tabs) opened for App2 should be closed.
I tried capturing window objects of App2. And thought of using winObj.close() to close each one of them with a loop. But the problem is that how and where can I capture window Objects ? (I need to get those objects when user clicks on logout).
I tried in cookie and localStorage by using
localStorage.setItem('app2Window', JSON.stringify(window))
but JSON.stringify(window) gives me following error:
Uncaught TypeError: Converting circular structure to JSON --> starting at object with constructor 'Window' --- property 'window' closes the circle at JSON.stringify () at :1:41
Any help/pointers towards this problem will be appreciated.
Looks like the BroadcastChannel is what you're looking for: