Created
November 6, 2010 06:14
-
-
Save kara-ryli/665231 to your computer and use it in GitHub Desktop.
How to set the <body> tag's height to the full window height and still get it right on the iPhone.
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
window.onload = function () { | |
var s = document.body.style; | |
s.height = window.screen.availHeight + 'px'; | |
setTimeout(function () { | |
window.scrollTo(0, 0); | |
s.height = window.innerHeight + 'px'; | |
}, 50); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have no idea how long I had to poke on this to get it right. The iPhone lies about a lot of things; window.innerHeight, window.scrollY are the fun ones.