-
-
Save grahams/1042408 to your computer and use it in GitHub Desktop.
Prevent links in standalone web apps opening Mobile Safari
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mobile Safari in standalone mode | |
if(("standalone" in window.navigator) && window.navigator.standalone){ | |
window.addEventListener("load",function() { | |
links = document.getElementsByTagName('a'); | |
for (var i=0; i < links.length; i++) | |
{ | |
// Don't do this for javascript: links | |
if(links[i].href.toLowerCase().indexOf('javascript') !== 0) | |
{ | |
links[i].addEventListener("click",function(event){ | |
top.location.href = this.href; | |
event.returnValue = false; | |
},false); | |
} | |
} | |
},false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment