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

LeetCode:622. 设计循环队列【模拟循环队列】

腾讯云孟凡杰:我所经历的云原生降本增效最佳实践案例

Meta 与苹果的元宇宙碰撞

In action: 10 ways to implement delayed tasks, with code!

如何ES源码中添加一个自己的API 流程梳理

Leetcode刷题——单调栈问题(739每日温度问题、496下一个更大元素I、503下一个更大元素 II)

GNN教程:图神经网络基础知识!

J9数字论:互联网跨链桥有什么作用呢?

Introduction of uncommon interfaces of openlayers

OP analysis and design
随机推荐
golang source code analysis: uber-go/ratelimit
Golang source code analysis: time/rate
程序员也许都缺一个“二舅”精神
Redis cluster configuration
TodoList案例
J9数字货币论:识别Web3新的稀缺性:开源开发者
LeetCode - 105. 从前序与中序遍历序列构造二叉树;023.合并K个升序链表
有效解决MySQL报错:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO/YES)
V - memo new instructions
顺序查找和折半查找,看这篇就够了
pytorch的tensor创建和操作记录
ssdp协议搜索GB28181设备
setup syntax sugar defineProps defineEmits defineExpose
SQL 入门之第一讲——MySQL 8.0.29安装教程(windows 64位)
golang源码分析之geoip2-golang
Linphone 被叫方如何解析来电SIP消息中的自定义头消息
LeetCode 622 设计循环队列[数组 队列] HERODING的LeetCode之路
Caldera(一)配置完成的虚拟机镜像及admin身份简单使用
磁盘分区的知识
SQL Server实现group_concat功能