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

前端 未结 2 1004
盖世英雄少女心
盖世英雄少女心 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.

提交回复
热议问题