Force link to open in mobile safari from a web app with javascript
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
Safari Webapp force to open Safari when click another link
I solved it by using javascript to redirecting instead of using a tag.
Related Topics
Get Selected Value in Dropdown List Using JavaScript
How to Return the Response from an Asynchronous Call
How to Access the Correct 'This' Inside a Callback
How to Print a Number With Commas as Thousands Separators in JavaScript
Calculate Distance Between Two Points in Google Maps V3
Accessing Nested JavaScript Objects and Arrays by String Path
What Are the Nuances of Scope Prototypal/Prototypical Inheritance in Angularjs
What Is the Most Efficient Way to Deep Clone an Object in JavaScript
How to Format a Date in JavaScript
Which Equals Operator (== VS ===) Should Be Used in JavaScript Comparisons
JavaScript Infamous Loop Issue
What Is the Purpose of the Var Keyword and When Should I Use It (Or Omit It)
Use a Content Script to Access the Page Context Variables and Functions
How to Redirect to Another Webpage
Object Comparison in JavaScript