[英]Web mobile reliable height
Does anybody knows how can I get the exact client height on a mobile device using JavaScript? 有人知道如何使用JavaScript在移动设备上获得确切的客户端高度吗? I need to have the visible height (all page height except the keyboard (if displayed) and the address bar (if visible)).
我需要具有可见的高度(除键盘(如果显示)和地址栏(如果可见)之外的所有页面高度)。 I tried with window.innerHieght and document.documentElement.clientHeight but the returned values are not always reliable.
我尝试使用window.innerHieght和document.documentElement.clientHeight,但是返回的值并不总是可靠的。 On iOS and Android, randomically when loading the page and showing/hideing the keyboard, the height is the height without the keyboard even if the keyboard is not visible.
在iOS和Android上,加载页面并显示/隐藏键盘时, 随机地 ,高度是没有键盘的高度,即使键盘不可见。
Seems you can get answer from here: How to calculate height of viewable area (ie, window height minus address & bookmark bars) in mobile Safari for web app? 似乎您可以从这里获得答案: 如何在Web应用程序的移动Safari中计算可见区域的高度(即,窗口高度减去地址和书签栏)?
For example on ios7 safari: 例如在ios7 Safari中:
window.innerHieght is 529px which is the viewport height window.innerHieght为529px,这是视口高度
screen.availHeight is 548px which is the window.innerHeight plus address height screen.availHeight为548px,即window.innerHeight加上地址高度
screen.height is 568px which is the screen.availHeight plus status bar screen.height为568px,即screen.availHeight加上状态栏
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.