Created
May 3, 2014 16:35
-
-
Save chriskief/fe4f56ca3e15f2610fb8 to your computer and use it in GitHub Desktop.
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
# based on http://stanislav.it/how-to-prevent-ios-standalone-mode-web-apps-from-opening-links-in-safari/ | |
if window.navigator.standalone? | |
noddy = false | |
remotes = false | |
document.addEventListener 'click', (event) -> | |
noddy = event.target | |
while noddy.nodeName isnt 'A' and noddy.nodeName isnt 'HTML' | |
noddy = noddy.parentNode | |
if noddy.href? and !!~ noddy.href.indexOf('http') and (!!~ noddy.href.indexOf(document.location.host) || remotes) | |
event.preventDefault() | |
document.location.href = noddy.href | |
return | |
, false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment