Last time I got a web APP for my website based on the tutorials on the web, but it was very bad for the users.
Problem Description:
What's wrong? It turns out that when you open the Web app and open the connection on the home page, you'll open the Safari browser. The original good disguise and mood are all destroyed. What's the best way to do that? The original solution is very simple. Just add the code. The test was passed on my iphone (iOS 7.1) and ipod (iOS 6.1.4), according to the original author's account, the latest IOS 7.0.4 (IPhone and IPad) test passed, the code should be good compatibility, here to share:
Problem solving:
Copy Code code as follows:
<script type= "Text/javascript" >
The question of clicking the link in the IOS Web app to jump to the new tab page of Safari browser
if (("standalone" in Window.navigator) && Window.navigator.standalone) {
var noddy, remotes = false;
Document.addeventlistener (' click ',
function (event) {
Noddy = Event.target;
while (Noddy.nodename!== "A" && noddy.nodename!== "HTML") {
Noddy = Noddy.parentnode;
}
if (' href ' in Noddy && noddy.href.indexOf (' http ')!==-1 && (Noddy.href.indexOf (document.location.host) !==-1 | | Remotes)) {
Event.preventdefault ();
Document.location.href = Noddy.href;
}
},
FALSE);
}
</script>
It is recommended to put the code before the/head tag, of course, another save as a JS file reference is also possible.