Skip to content

Instantly share code, notes, and snippets.

@chriskief
Created May 3, 2014 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriskief/fe4f56ca3e15f2610fb8 to your computer and use it in GitHub Desktop.
Save chriskief/fe4f56ca3e15f2610fb8 to your computer and use it in GitHub Desktop.
# 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