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

落花浮王杯 提交于 2019-12-04 03:59:16

问题


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?


回答1:


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.



回答2:


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



来源:https://stackoverflow.com/questions/32952980/is-it-possible-to-hide-url-bar-in-ios-9-safari-browser-by-using-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!