How to hide a mobile browser's address bar?

前端 未结 6 778
小蘑菇
小蘑菇 2020-11-30 05:16

Safari and Chrome on mobile devices both include a visible address bar when a page loads. As the body of the page scrolls, these browsers will scroll the addres

相关标签:
6条回答
  • 2020-11-30 05:58

    Have a look at this HTML5 rocks post - http://www.html5rocks.com/en/mobile/fullscreen/ basically you can use JS, or the Fullscreen API (better option IMO) or add some metadata to the head to indicate that the page is a webapp

    0 讨论(0)
  • 2020-11-30 06:02

    I know this is old, but I have to add this in here..

    And while this is not a full answer, it is an 'IN ADDITION TO'

    The address bar will not disappear if you're NOT using https.

    ALSO

    If you are using https and the address bar still won't hide, you might have some https errors in your webpage (such as certain images being served from a non-https location.)

    Hope this helps..

    0 讨论(0)
  • 2020-11-30 06:05

    The easiest way to archive browser address bar hiding on page scroll is to add "display": "standalone", to manifest.json file.

    0 讨论(0)
  • 2020-11-30 06:08

    In my case problem was in css and html layout. Layout was something like html - body - root - ... html and body was overflow: hidden, and root was position: fixed, height: 100vh.

    Whith this layout browser tabs on mobile doesnt hide. For solve this I delete overflow: hidden from html and body and delete position: fixed, height: 100vh from root.

    0 讨论(0)
  • 2020-11-30 06:08

    You can go to fullscreen when user allows it :)

    <button id="goFS">Go fullscreen</button>
    <script>
      var goFS = document.getElementById("goFS");
      goFS.addEventListener("click", function() {
          
       const elem = document.documentElement;
       if (elem.requestFullscreen) {elem.requestFullscreen()}
       
      }, false);
    </script>
    
    0 讨论(0)
  • 2020-11-30 06:22

    This should be the code you need to hide the address bar:

    window.addEventListener("load",function() {
        setTimeout(function(){
            // This hides the address bar:
            window.scrollTo(0, 1);
        }, 0);
    });
    

    Also nice looking Pokedex by the way! Hope this helps!

    0 讨论(0)
提交回复
热议问题