最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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?

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?

Share Improve this question edited Apr 23, 2018 at 18:54 Peter Mortensen 31.6k22 gold badges110 silver badges133 bronze badges asked Oct 5, 2015 at 16:07 Aircraft5Aircraft5 1771 gold badge1 silver badge13 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

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

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

Working code example: http://pastebin./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)

  1. 暂无评论