-
-
Save bronfman/4328383 to your computer and use it in GitHub Desktop.
Revisions
-
kylebarrow revised this gist
Jun 24, 2011 . 2 changed files with 30 additions and 13 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ <!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 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 charactersOriginal file line number Diff line number Diff line change @@ -1,21 +1,23 @@ // Mobile Safari in standalone mode if(("standalone" in window.navigator) && window.navigator.standalone){ // If you want to prevent remote links in standalone web apps opening Mobile Safari, change 'remotes' to true var noddy, remotes = false; document.addEventListener('click', function(event) { noddy = event.target; // Bubble up until we hit link or top HTML element. Warning: BODY element is not compulsory so better to stop on HTML 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); } -
kylebarrow revised this gist
Jun 24, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ if(("standalone" in window.navigator) && window.navigator.standalone){ window.addEventListener("load",function() { var links = document.getElementsByTagName('a'); for (var i=0; i < links.length; i++) { -
kylebarrow created this gist
Jun 23, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ // 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); }