从一个应用程序关闭不同的浏览器选项卡
我有2个应用程序,当我们单击App1中的链接时,可以访问App2。 每次单击此链接时,都会打开一个包含App2的新浏览器选项卡。
现在,我有一个要求,在注销App1时,应关闭针对App2打开的所有实例(TABS)。
我尝试捕获App2的窗口对象。并考虑使用winobj.close()
用循环关闭其中的每个>。但是问题是如何以及在哪里可以捕获窗口对象? (当用户单击注销时,我需要获取这些对象)。
我尝试使用cookie和localstorage localstorage.setItem('app2window',json.stringify(window))
但是JSON.STRINGIFY(窗口)给我以下错误:
uck typeerror:将圆形结构转换为JSON - >从构造函数“窗口”开始从对象开始 ---属性“窗口”关闭了圆圈 在json.stringify() 在:1:41
对此问题的任何帮助/指针都将不胜感激。
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 usinglocalStorage.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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您要寻找的是广播渠道:
它的主要目的是在同一来源的脚本之间进行一对多的通信。
Looks like the BroadcastChannel is what you're looking for:
it's main purpose is for one-to-many communication between scripts on the same origin.