Skip to content

Instantly share code, notes, and snippets.

@por
Forked from kylebarrow/example.html
Created June 23, 2011 09:23
Show Gist options
  • Save por/1042215 to your computer and use it in GitHub Desktop.
Save por/1042215 to your computer and use it in GitHub Desktop.
Prevent links in standalone web apps opening Mobile Safari
// 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