首页 > 解决方案 > 如何根据 URL 或参数关闭浏览器选项卡?

问题描述

我有一个 Web 应用程序,其中一部分在子选项卡中打开了第 3 方页面(我无法将其设置为 iframe,因为他们发送的标题阻止了它)一旦用户完成第 3 方页面,第 3 方显示一个空白在“SUCCESS”的 URL 中带有 GET 参数的白页。

我希望能够从主选项卡中查询 url,如果它包含“SUCCESS”,请关闭子窗口。

这需要跨浏览器兼容并使用 Javscript / Jquery 编写任何想法?这可能吗?

标签: javascriptjquerybrowser

解决方案


As far as i know (someone please mention otherwise), you can not trigger the browser to close an external page.
That would be a major security issue, imagine if you visited a site, and it decided to close all your other tabs ? Opens to many malicious possibilities..

Also regarding PWA, the possibilities are limited as to their power, depending on the phone, they run inside more or less restricted frames of the browser, especially on iOs..

Maybe you can look into “bypassing” the iframe restrictions, that way you’d simply be able to toggle it off with JS or even Css.
What are those restrictions, do you have code?

Also, how you invoked that 3rd party page to open in the background, could be relevant.


推荐阅读