eternityz

正常值为100,如果放大到150%,则显示150

//获取当前页面的缩放值
function detectZoom() {
    var ratio = 0,
        screen = window.screen,
        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;
}

分类:

技术点:

相关文章:

  • 2021-07-06
  • 2021-10-22
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2022-02-23
  • 2021-06-13
  • 2021-07-19
猜你喜欢
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2021-12-18
  • 2022-02-28
  • 2021-12-25
相关资源
相似解决方案