Skip to content

Instantly share code, notes, and snippets.

@courtsimas
Created April 3, 2012 21:54
Show Gist options
  • Save courtsimas/2295765 to your computer and use it in GitHub Desktop.
Save courtsimas/2295765 to your computer and use it in GitHub Desktop.
hide url bar
// Hide URL bar for iOS and android
hideAddressBar = function(){
if (navigator.userAgent.match(/Android/i)) {
window.scrollTo(0,0); // reset in case prev not scrolled
var nPageH = $(document).height();
var nViewH = window.outerHeight;
if (nViewH > nPageH ) {
nViewH = nViewH / window.devicePixelRatio;
$('body').css('height',nViewH + 'px');
}
window.scrollTo(0,1);
}else if(navigator.userAgent.match(/iPhone|iPod/i)) {
setTimeout(hideURLbar, 0);
addEventListener("load", function() {
setTimeout(hideURLbar, 0);
setTimeout(hideURLbar, 500);
}, false);
}
function hideURLbar(){
if(!pageYOffset){
window.scrollTo(0,0);
}
}
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment