Is it possible to hide URL bar in iOS 9 (Safari br

2019-02-23 12:23发布

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:

window.scrollTo(0, 0);

But it doesn't work. The URL bar is still visible. How do I solve this problem?

2条回答
做个烂人
2楼-- · 2019-02-23 13:11

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

查看更多
该账号已被封号
3楼-- · 2019-02-23 13:27

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.
查看更多
登录 后发表回答