Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
28
rated 0 times [  31] [ 3]  / answers: 1 / hits: 56489  / 13 Years ago, fri, october 28, 2011, 12:00:00

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.


More From » ios

 Answers
38

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


[#89400] Thursday, October 27, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jazminuniquer

Total Points: 63
Total Questions: 121
Total Answers: 96

Location: Cambodia
Member since Thu, May 21, 2020
4 Years ago
;