js 查看浏览器缩放比例,不是100% 则给出提示

查看浏览器缩放比例,不是 100% 则给出提示

let rate = ChangeRatio();
console.log("sr" + rate);
if(rate != 100){
   alert('当前页面不是100%显示,请按键盘ctrl+0恢复100%显示标准,以防页面显示错乱!');
}

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;
}

上一篇:tensorflow---优化器的使用


下一篇:TensorFlow中学习率衰减的简单笔记