zoukankan      html  css  js  c++  java
  • 谷歌模拟手机和真机上显示的各个机型的 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

  • 相关阅读:
    【POJ 2987】Firing (最小割-最大权闭合子图)
    -网络流经典模型
    【bzoj 3299】 [USACO2011 Open]Corn Maze玉米迷宫(最短路)
    【POJ 3623】 Best Cow Line, Gold (后缀数组)
    题表-各种生成树
    yield 生成器的运行机制
    numpy.random.shuffle(x)的用法
    Softmax回归(Softmax Regression
    softmax 函数
    极大似然估计的朴素理解
  • 原文地址:https://www.cnblogs.com/hamsterPP/p/5022073.html
Copyright © 2011-2022 走看看