Created
May 13, 2013 12:44
-
-
Save detrick/5568062 to your computer and use it in GitHub Desktop.
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
(function() { | |
var hideUrlBar = function () { | |
var win = window, | |
doc = win.document; | |
// If there's a hash, or addEventListener is undefined, stop here | |
if( !location.hash || !win.addEventListener ){ | |
//scroll to 1 | |
window.scrollTo( 0, 1 ); | |
var scrollTop = 1, | |
//reset to 0 on bodyready, if needed | |
bodycheck = setInterval(function(){ | |
if( doc.body ){ | |
clearInterval( bodycheck ); | |
scrollTop = "scrollTop" in doc.body ? doc.body.scrollTop : 1; | |
win.scrollTo( 0, scrollTop === 1 ? 0 : 1 ); | |
} | |
}, 15 ); | |
win.addEventListener( "load", function(){ | |
setTimeout(function(){ | |
//reset to hide addr bar at onload | |
win.scrollTo( 0, scrollTop === 1 ? 0 : 1 ); | |
}, 0); | |
}, false ); | |
} | |
}; | |
hideUrlBar(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment