[SOLVED] Unable to Open and Close Popup window in JavaScript when viewed in Android Frames

Issue

This Content is from Stack Overflow. Question asked by uncommon_name

I open a new tab to show the user some info using:

window.open("/Home/Agreement", "_blank");

Inside the Agreement View, I put a button with this JavaScript to close the Popup and return to the main tab:

<button class="btn btn-primary btn-block" onclick="window.close();">
     return to home
</button>

This method works well in Desktop and also when viewed through a standalone browser in Mobile, but when users navigate to the main page through embedded Web View in Instagram:

They cannot close the popup tab using the button. The button does nothing… and when they press back on their mobile phone, the main page is refreshed, and form input is lost.



Solution

Nevermind,
I fixed it by detecting if the page is open in Instagram agent and redirected it to an external browser with the help of this question on SO:

Open link in External Browsers


This Question was asked in StackOverflow by uncommon_name and Answered by uncommon_name It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?