zoukankan      html  css  js  c++  java
  • JS 获取浏览器显示比例,缩放比例

    JS不能调整浏览器的显示比例,仅能查看

    //调整浏览器显示比例【仅能查看】
    function ChangeRatio()
    {
        var ratio=0;
        var screen=window.screen;
        var ua=navigator.userAgent.toLowerCase();
    
        if(window.devicePixelRatio !== undefined)
        {
            ratio=window.devicePixelRatio;    
        }
        else if(~ua.indexOf('msie'))
        {
            if(screen.deviceXDPI && screen.logicalXDPI)
            {
                ratio=screen.deviceXDPI/screen.logicalXDPI;        
            }
        
        }
        else if(window.outerWidth !== undefined && window.innerWidth !== undefined)
        {
            ratio=window.outerWidth/window.innerWidth;
        }
    
        if(ratio)
        {
            ratio=Math.round(ratio*100);    
        }
        return ratio;
    }
  • 相关阅读:
    统计字符
    两军交锋
    FatMouse' Trade
    A + B Problem II
    Number Sequence
    Max Sum
    类的设计
    类与对象
    面向对象思想
    第一个OC程序
  • 原文地址:https://www.cnblogs.com/dyhao/p/11458882.html
Copyright © 2011-2022 走看看