I use this JavaScript code to hide the address bar in mobile Safari:
window.addEventListener("load",function() {
setTimeout(function(){
window.scrollTo(0, 1);
}, 0);
});
It works great and doesn’t do any harm to other browsers. Only Internet Explorer 8 (which is the oldest IE I have to support) seems to be having problems with it as any JavaScript that comes after that code block isn’t executed anymore. Do you have any idea why?
I already googled that some people have problems with scrollTo in IE8, but the only resource that could have been helpful was a link to a bug report for jQuery 1.3.3 or something like that. As I am using jQuery 1.9.0 I believe that problem was solved in the meantime.
By the way: Why wasn’t I able to find the scrollTo method in the jQuery docs? It seems to be some kind of plugin?
Damn, that was a tricky one! But the problem simply was that IE8 does not know
addEventListener– can you imagine that? Instead, IE8 needsattachEvent, see here.