Вопрос

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?

Это было полезно?

Решение

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

Другие советы

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

$('#elemIdTOScroll')[0].scrollIntoView(true);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top