谷歌模拟手机和真机上显示的各个机型的 dpi--和高度

 **以下数据尚未经过严密测试、待日后工作中再试**

var dpi = window.devicePixelRatio;//获取屏幕分辨率
alert("dpi为:"+dpi);
alert("$(window).height()为:"+$(window).height());
alert("document.body.offsetHeight:"+document.body.offsetHeight);
alert("window.innerHeight:"+window.innerHeight);
alert("document.documentElement.clientHeight:"+document.documentElement.clientHeight)
alert("window.screen.availHeight:"+window.screen.availHeight);

var currentScreenHeight =$(window).height()/dpi; 好像并不需要除以dpi了,不晓得咋回事,可能是哪里有写错,以后再说

=====================================分割线==================================================

各个屏幕测试 dpi--$(window).height()--document.body.offsetHeight-- window.innerHeight--document.documentElement.clientHeight--window.screen.availHeight
谷歌模拟6 plus:  3 736 736 736 736 736
谷歌模拟note3: 3 640 640 640 640 640
谷歌模拟5:    2 568 568 568 568 568

苹果5 真机:   2 460 460 460 460 460 548
联想真机(公司机子,型号未知):2 640 640 640 640 1280
魅族真机(公司机子,型号未知): 3 640 640 640 1920

总结:如此看来,手机端动态获取高度,除了不能用window.screen.availHeight以外,其他都能用
有人说scrollHeight|width也可以,我没有试过。
返回的数值需要除以手机的dp1

原文地址:https://www.cnblogs.com/hamsterPP/p/5022073.html