当前位置:网站首页>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;
};
边栏推荐
猜你喜欢

你是几星测试/开发程序员?技术型选手王大拿......

第七章 噪声

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

遇上Mysql亿级优化,怎么办

Flutter with internationalized adapter automatically generated
![LeetCode 622 设计循环队列[数组 队列] HERODING的LeetCode之路](/img/dc/ba5a0c3f6a58283d79c5916376e49e.png)
LeetCode 622 设计循环队列[数组 队列] HERODING的LeetCode之路

Introduction of uncommon interfaces of openlayers

Fetch 请求不转换BLOB正常显示GBK编码的数据

LM小型可编程控制器软件(基于CoDeSys)笔记二十五:plc的数据存储区(数字量输入通道部分)

分布式事务
随机推荐
PG 之 SQL执行计划
Async的线程池使用的哪个?
顺序查找和折半查找,看这篇就够了
如何ES源码中添加一个自己的API 流程梳理
J9数字论:互联网跨链桥有什么作用呢?
「面试必会」这应该是最有深度的TCP三次握手、四次挥手细节讲解
2170. 使数组变成交替数组的最少操作数
Fetch 请求不转换BLOB正常显示GBK编码的数据
TodoList案例
网络协议介绍
一款好用的FAQ搭建工具
"A daily practice, happy water problem" 1374. Generate a string with an odd number of each character
实现fashion_minst服装图像分类
Translate My Wonderful | July Moli Translation Program Winners Announced
线程安全(上)
OP analysis and design
B站HR对面试者声称其核心用户都是生活中的Loser
V - memo new instructions
Wintun:一款惊艳的 WireGuard 虚拟网卡接口驱动
ImageNet下载及处理