Is it possible to hide URL bar in iOS 9 (Safari browser) by using JavaScript?

前端 未结 2 1001
盖世英雄少女心
盖世英雄少女心 2021-01-19 16:35

I want to hide the URL bar from my single-page application by using JavaScript.

I tried to set bigger height of the \'body\' element and then perform:



        
相关标签:
2条回答
  • 2021-01-19 17:23

    For iPhone, you can make your content just one pixel higher than the viewport, that will eliminate the navbar.

    Working code example: http://pastebin.com/16s8Xvbw

    Caveats:

    • Only works in landscape, and when flipping from portrait to landscape - if user enters the page in landscape, he/she must flip to portrait and back to landscape.
    • If the user touches near top / bottom, navbar will re-appear.
    • Does not work on iPad at all.
    0 讨论(0)
  • 2021-01-19 17:24

    so far it seems it doesn't work on iOS 9, it stopped working after iOS 7.1.

    As seen here:

    Impossible to hide navigation bars in Safari iOS 7 for iPhone/iPod touch

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