Domanda

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?

È stato utile?

Soluzione

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

Altri suggerimenti

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

$('#elemIdTOScroll')[0].scrollIntoView(true);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top