When calling window.open()
in a iOS web app, the page opens in the web app instead of mobile safari.
How can I force the webpage to open in mobile safari?
Note: Using straight <a href>
links is not an option.
There is no way to force it to open the url in safari and not open the app. Every app will have list of urls that it can open. So you have to go to that app settings and tell that it should open in browser for the urls and not in the app.
This is possible. Tested with iOS5 stand-alone web app:
HTML:
<div id="foz" data-href="http://www.google.fi">Google</div>
JavaScript:
document.getElementById("foz").addEventListener("click", function(evt) { var a = document.createElement('a'); a.setAttribute("href", this.getAttribute("data-href")); a.setAttribute("target", "_blank"); var dispatch = document.createEvent("HTMLEvents"); dispatch.initEvent("click", true, true); a.dispatchEvent(dispatch); }, false);
Can be tested here: http://www.hakoniemi.net/labs/linkkitesti.html
Turns out it is NOT POSSIBLE to escape the iOS web app with a JavaScript window.open()
. If you want a link to open in mobile safari you have to use <a href>
links.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With