Skip to content

Instantly share code, notes, and snippets.

@trumbitta
Created September 29, 2011 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trumbitta/1250462 to your computer and use it in GitHub Desktop.
Save trumbitta/1250462 to your computer and use it in GitHub Desktop.
A snippet taken from BostonGlobe.com for a proper hiding of the address bar in crappy webkit browsers as mine in HTC Desire :p
//Thx to Ethan Marcotte, anyway
//scroll to top, hide address bar on mobile devices - 1 for android, 0 for the rest
if( !location.hash ){
//scroll to top
window.scrollTo( 0, 1 );
var scrollTop = 1,
getScrollTop = function(){
return "scrollTop" in doc.body ? doc.body.scrollTop : 1;
};
//reset to 0 on bodyready, if needed
globe.bodyready(function(){
var scrollTop = getScrollTop();
window.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
});
window.onload = function(){
setTimeout(function(){
//reset to hide addr bar at onload
if( getScrollTop() < 20 ) {
window.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
}
}, 0);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment