Skip to content

Instantly share code, notes, and snippets.

@QaDeS
Created March 5, 2013 09:57
Show Gist options
  • Save QaDeS/5089192 to your computer and use it in GitHub Desktop.
Save QaDeS/5089192 to your computer and use it in GitHub Desktop.
Reliably hides the address bar on mobile browsers.
hideAddressBar = ->
inScroll = false
fun = ->
return true if inScroll
inScroll = true
de = document.documentElement
h = window.outerHeight/window.devicePixelRatio
if de.scrollHeight < h
de.style.height = h + 'px'
window.scrollTo 0, 1
inScroll = false
return false
window.addEventListener "load", fun
window.addEventListener "orientationchange", fun
window.onscroll = fun
setTimeout fun, 100
hideAddressBar()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment