当前位置:网站首页>js如何获取浏览器缩放比例
js如何获取浏览器缩放比例
2022-08-02 20:02: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;
};
边栏推荐
猜你喜欢

TPAMI2022 | TransCL:基于Transformer的压缩学习,更灵活更强大

译出我精彩 | 7月墨力翻译计划获奖名单公布

特拉维夫大学 | Efficient Long-Text Understanding with Short-Text Models(使用短文本模型进行高效的长文本理解)
Solve the docker mysql can't write Chinese

磁盘分区的知识

一次线上事故,我顿悟了异步的精髓

对话亚洲高校首个博士论文奖-裘捷中丨KDD2022

【数据分析】:什么是数据分析?

Parse common methods in the Collection interface that are overridden by subclasses

Implement fashion_minst clothing image classification
随机推荐
MOSN 反向通道详解
第一次进入前20名
ALV report learning summary
Golang source code analysis: time/rate
所谓武功再高也怕菜刀-分区、分库、分表和分布式的优劣
Axure9的元件用法
Flutter with internationalized adapter automatically generated
arm64麒麟安装paddlehub(国产化)
【 LeetCode 】 1374. Generate each character string is an odd number
Thread线程类基本使用(上)
扫码预约 | 观看Apache Linkis数据处理实践以及计算治理能力
技术分享 | Apache Linkis 快速集成网页IDE工具 Scriptis
shell:条件语句
实现客户服务自助,打造产品知识库
线程安全(上)
golang源码分析之geoip2-golang
OP-5,输入/输出信号范围-一信号处理能力
ShardingSphere-proxy +PostgreSQL implements read-write separation (static strategy)
ShardingSphere-proxy +PostgreSQL实现读写分离(静态策略)
setup syntax sugar defineProps defineEmits defineExpose