Created
April 3, 2012 21:54
-
-
Save courtsimas/2295765 to your computer and use it in GitHub Desktop.
hide url bar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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