Created
September 29, 2011 10:19
-
-
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
This file contains 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
//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