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

javascript - Detect when the Chrome for iOS address bar is showing - Stack Overflow

programmeradmin1浏览0评论

I have set the apple-mobile-web-app-capable to true in my web app's head section. All good, Chrome tries to hide the address bar when possible to give more room to the web app.

Problem is that my app's navigation is on the top and goes behind the address bar during that time. I was wondering if there is a way I could detect when the address bar is showing and dropping the navigation below the address bar.

If I remove the apple-mobile-web-app-capable meta tag, address bar shows, but the navigation still goes behind it. For some reason Chrome sets the window size to the size of the screen, but pulls the address bar on top of it.

Is anyone aware of any solutions to this?

I have set the apple-mobile-web-app-capable to true in my web app's head section. All good, Chrome tries to hide the address bar when possible to give more room to the web app.

Problem is that my app's navigation is on the top and goes behind the address bar during that time. I was wondering if there is a way I could detect when the address bar is showing and dropping the navigation below the address bar.

If I remove the apple-mobile-web-app-capable meta tag, address bar shows, but the navigation still goes behind it. For some reason Chrome sets the window size to the size of the screen, but pulls the address bar on top of it.

Is anyone aware of any solutions to this?

Share Improve this question edited Sep 2, 2013 at 11:42 Jawa 2,3326 gold badges34 silver badges39 bronze badges asked Apr 21, 2013 at 11:00 MehdiMehdi 8332 gold badges11 silver badges16 bronze badges 3
  • 1 This is driving me crazy, too. Exactly the same issue. When the user's scroll delta is negative, then the address bar pops in, hiding my navigation. The resize event is even fired. – oliverseal Commented May 20, 2013 at 5:54
  • Yeah, haven't been able to find a proper solution to this so far. – Mehdi Commented May 31, 2013 at 13:56
  • Mehdi: is the issue resolved. Me too facing the same issue. – Wasim Commented Jul 22, 2013 at 15:13
Add a ment  | 

1 Answer 1

Reset to default 4

There is a workaround around this actually; you just have to force your app to scroll down by 1px (enough to hide the Chrome address bar) :

setTimeout(function() {
  // Already scrolled?
  if(window.pageYOffset !== 0) return;

  window.scrollTo(0, window.pageYOffset + 1);
}, 1);
发布评论

评论列表(0)

  1. 暂无评论