iOS Chrome-如何计算窗口高度减去地址栏的高度 [英] iOS Chrome - How to calculate window height minus height of address bar

查看:71
本文介绍了iOS Chrome-如何计算窗口高度减去地址栏的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发的浏览器游戏的主体中只有一个全尺寸的画布元素. 在iOS9.2(iPad)Chrome(版本47.0.2526.107)中运行这些游戏时,游戏屏幕的底部区域不会显示. (几个月前没有发生.即使现在,这也没有发生在Safari中,也没有发生在Android 5.0.2 Chrome 47.0.2526.83中)

I am developing browser games that have only one full-size canvas element in body. When run these games in iOS9.2(iPad) Chrome(Ver 47.0.2526.107), the bottom area of game screen is not shown. (It didn't happen several months ago. Even now this neither happen in Safari, nor Android 5.0.2 Chrome 47.0.2526.83)

这些游戏程序首先计算窗口的大小(显示地址栏时显示html文档的区域),然后放置具有该大小的canvas元素. 由于是某些版本的Chrome,因此未显示地址栏时,窗口大小"将被解释为窗口的大小.

These game programs first calculate size of window (the area showing html document when address bar is shown), and places a canvas element having the size. Since some version of Chrome, the "size of window" is interpreted as the size of window when address bar is NOT shown.

我尝试通过以下方法获取窗口的高度:

I tried to get the height of window by:

  • screen.availHeight
  • window.innerHeight
  • $(window).height()
  • document.documentElement.clientHeight
  • document.height
  • $(document).height()

但是它们都返回相同的值,即地址栏未显示时的高度.

but they all returns the same value, the height when address bar is NOT shown.

测试代码显示在 http://jsrun.it/hoge1e4/4Ygq 中显示地址栏时,知道屏幕底部的刻度值. (见图片)

Test code is shown in http://jsrun.it/hoge1e4/4Ygq I want to know the value of the scale at bottom of the screen when address bar is shown. (see picture)

推荐答案

该问题似乎可以通过版本升级解决.

The problem seems to be solved by version-up.

我在49.0.2623.73版上进行了检查

I checked it on ver.49.0.2623.73

这篇关于iOS Chrome-如何计算窗口高度减去地址栏的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆