Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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