-
-
Save adamcoulombe/5331569 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
var isiPhone = (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)); | |
var getWindowHeight = function(){ | |
// this was the most reliable way I could find of getting the actual viewport height without the status, address or button bar. | |
return isiPhone ? window.screen.availHeight - (window.navigator.standalone ? 0 : 44) : $(window).height(); | |
} | |
//Lose the address bar | |
$(window).load(function(){ | |
// http://stackoverflow.com/questions/2526315/strange-jquery-window-load-behavior-in-safari | |
// Checking for an offset forces safari for finish loading/layout out the content, it blocks javascript until the return completes. You can use it like this: | |
var block = document.body.offsetWidth; | |
// Set a timeout... | |
if(isiPhone){ | |
setTimeout(function(){ | |
window.scrollTo(0, 1); | |
}, 0); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment