当前位置:网站首页>js how to get the browser zoom ratio
js how to get the browser zoom ratio
2022-08-02 23:38:00 【hzxOnlineOk】
function getZoom(){
let 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;
};
边栏推荐
猜你喜欢
随机推荐
ABAP grammar small review
博客主页rrs代码
第七章 噪声
PyTorch分布式backends
【数据分析】:什么是数据分析?
arm64麒麟安装paddlehub(国产化)
有效解决MySQL报错:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO/YES)
MSTP与STP
php 单引号 双引号 -> => return echo
.NET如何快速比较两个byte数组是否相等
软件成分分析:华为云重磅发布开源软件治理服务
什么是 IDE
Day35 LeetCode
基于“无依赖绝对定位”实现的圣杯三栏布局
六石管理学:入门机会只有一次,先把产品做好
Likou Question of the Day - Day 46 - 344. Reverse Strings
顺序查找和折半查找,看这篇就够了
golang 源码分析:juju/ratelimit
js: 实现一个cached缓存函数计算结果
TodoList案例