Question

I want to make my mobile web page auto scroll down to hide the browser search bar at the top of the page. An example of this is the Facebook home page on mobile, it auto scrolls down as soon as it loads so you almost feel like you're in an app and not a browser. Problem is each operating system has a different size for their browser search bar. Is there a property I can call to get its size or to autoscroll past it?

Était-ce utile?

La solution

From Hide the Address Bar within Mobile Safari

window.addEventListener("load",function() {
  // Set a timeout...
  setTimeout(function(){
    // Hide the address bar!
    window.scrollTo(0, 1);
  }, 0);
});

Hope this helps

Autres conseils

Here is the solution to make the auto scroll work in mobile browsers

$('#elemIdTOScroll')[0].scrollIntoView(true);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top