Created
July 7, 2017 15:06
-
-
Save Vadizar/b68effcee06d1b21404224eff618df1a to your computer and use it in GitHub Desktop.
Prevent links in standalone web apps opening Mobile Safari
This file contains 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
<!DOCTYPE html> | |
<head> | |
<title>Stay Standalone</title> | |
<meta name="apple-mobile-web-app-capable" content="yes"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> | |
<script src="stay_standalone.js" type="text/javascript"></script> | |
</head> | |
<body> | |
<ul> | |
<li><a href="http://google.com/">Remote Link (Google)</a></li> | |
<li><a href="javascript:alert('Awesome script is awesome')">JavaScript Link</a></li> | |
<li><a href="/">Local Link</a></li> | |
<li><a href="#amp">Local Anchor</a></li> | |
</ul> | |
</body> |
This file contains 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(window.navigator.standalone){ | |
var a=document.getElementsByTagName("a"); | |
for(var i=0;i<a.length;i++) { | |
a[i].onclick=function() { | |
window.location=this.getAttribute("href"); | |
return false | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Used on http://1000.tech/en