Skip to content

Instantly share code, notes, and snippets.

@danro
Forked from mhammonds/HideMobileAddressBar.js
Created October 28, 2011 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danro/1322906 to your computer and use it in GitHub Desktop.
Save danro/1322906 to your computer and use it in GitHub Desktop.
Hide Browser Address Bar - Android + iPhone
function configAddressBar (addHeight) {
var defaultHeight = 50;
if (typeof addHeight == "undefined") addHeight = 1;
function hideAddressBar() {
if(!window.location.hash)
{
if(document.height < window.outerHeight)
{
document.body.style.height = (window.outerHeight + defaultHeight + addHeight) + 'px';
}
window.scrollTo(0, addHeight);
}
}
window.addEventListener("load", function(){ if(!window.pageYOffset){ hideAddressBar(); } } );
window.addEventListener("orientationchange", hideAddressBar );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment