当前位置:网站首页>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;
};
边栏推荐
- 太魔人招新啦|快来加入我们吧!
- 2170. 使数组变成交替数组的最少操作数
- 9,共模抑制比一-不受输入信号中共模波动的影响。【如何分析共模CM抑制比。】
- 顺序查找和折半查找,看这篇就够了
- A Review of Nature Microbiology: Focusing on the Algae--Ecological Interface of Phytoplankton-Bacteria Interactions
- es 读流程源码解析
- 有效解决MySQL报错:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO/YES)
- setup语法糖 defineProps defineEmits defineExpose
- 姑姑:给小学生出点口算题
- 【数据分析】:什么是数据分析?
猜你喜欢

「 每日一练,快乐水题 」1374. 生成每种字符都是奇数个的字符串
![[AnXun cup 2019] easy_web](/img/26/c04bc8b9c65ac75ddd2696b48e1661.png)
[AnXun cup 2019] easy_web

译出我精彩 | 7月墨力翻译计划获奖名单公布
![[安洵杯 2019]easy_web](/img/26/c04bc8b9c65ac75ddd2696b48e1661.png)
[安洵杯 2019]easy_web

SQL 入门之第一讲——MySQL 8.0.29安装教程(windows 64位)

Introduction of uncommon interfaces of openlayers

实战:10 种实现延迟任务的方法,附代码!

Five data structures of Redis and their corresponding usage scenarios

shell:条件语句

LeetCode - 105. 从前序与中序遍历序列构造二叉树;023.合并K个升序链表
随机推荐
谷歌竞价机器学习如何去理解?
如何ES源码中添加一个自己的API 流程梳理
「 每日一练,快乐水题 」1374. 生成每种字符都是奇数个的字符串
奥特学园ROS笔记--7(289-325节)
SQL Server安装教程
【LeetCode】1374. 生成每种字符都是奇数个的字符串
第七章 噪声
Helm基础知识
日志框架学习
Thread线程类基本使用(上)
J9数字货币论:识别Web3新的稀缺性:开源开发者
TPAMI2022 | TransCL:基于Transformer的压缩学习,更灵活更强大
9,共模抑制比一-不受输入信号中共模波动的影响。【如何分析共模CM抑制比。】
Translate My Wonderful | July Moli Translation Program Winners Announced
Introduction of uncommon interfaces of openlayers
ALV报表学习总结
ShardingSphere-proxy +PostgreSQL实现读写分离(静态策略)
J9数字论:互联网跨链桥有什么作用呢?
es DELETE index 源码分析
如何解决图像分类中的类别不均衡问题?不妨试试分开学习表征和分类器