Stu
Stu

Reputation: 1

How do I close a browser tab based on the URL or Parameters?

I have a web app, part of which opens a 3rd party page in a child tab (I'm unable to iframe it as the headers they send prevent it) Once the user has completed the 3rd party page, the 3rd party present a blank white page with a GET parameter in the URL of "SUCCESS".

I'd like to be able to interrogate the url from the main tab and if it contains "SUCCESS" close the child window.

This needs to be cross browser compliant and written using Javscript / Jquery Any ideas? is this possible?

Upvotes: 0

Views: 1223

Answers (1)

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.

Upvotes: 1

Related Questions