当前位置:网站首页>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 】 1374. Generate each character string is an odd number
- 9,共模抑制比一-不受输入信号中共模波动的影响。【如何分析共模CM抑制比。】
- Likou Question of the Day - Day 46 - 344. Reverse Strings
- LeetCode - 105. 从前序与中序遍历序列构造二叉树;023.合并K个升序链表
- GNN教程:图神经网络基础知识!
- 实现客户服务自助,打造产品知识库
- J9数字论:互联网跨链桥有什么作用呢?
- 训练双塔检索模型,可以不用query-doc样本了?明星机构联合发文
- Five data structures of Redis and their corresponding usage scenarios
- You want the metagenomics - microbiome knowledge in all the (2022.8)
猜你喜欢
随机推荐
Parse common methods in the Collection interface that are overridden by subclasses
LM小型可编程控制器软件(基于CoDeSys)笔记二十五:plc的数据存储区(数字量输入通道部分)
Leetcode刷题——23. 合并K个升序链表
setup语法糖 defineProps defineEmits defineExpose
EasyExcel实现动态列解析和存表
Geoserver+mysql+openlayers2
一次线上事故,我顿悟了异步的精髓
【StoneDB性能相关工具】内存监控
实战:10 种实现延迟任务的方法,附代码!
新增指令 v-memo
Lvm逻辑卷
【LeetCode】622. 设计循环队列
【数据分析】:什么是数据分析?
4 kmiles join YiSheng group, with more strong ability of digital business, accelerate China's cross-border electricity full domain full growth
【手撕AHB-APB Bridge】~ AMBA总线 之 APB
模板的进阶
云平台简介
TPAMI2022 | TransCL: based on the study the compression of the Transformer, more flexible and more powerful
Triacetin是什么化学材料
一些不错的博主








![[AnXun cup 2019] easy_web](/img/26/c04bc8b9c65ac75ddd2696b48e1661.png)
