判断浏览器缩放比例
2018-01-25 14:17
183 查看
function detectZoom (){
var 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;
};
detectZoom();
var 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;
};
detectZoom();
相关文章推荐
- 【浏览器】缩放是缩放CSS像素(缩放比例为1时,一个CSS像素等于一个屏幕像素)
- div等比例缩放-------纯CSS实现自适应浏览器宽度的正方形
- js浏览器缩放比例检测
- 如何判断微信内置浏览器(通过User Agent实现)
- java swing的背景图片按比例缩放
- js/jquery判断浏览器的方法小结
- 判断浏览器类型,区分手机和PC
- js和.Net判断浏览器
- 浏览器判断检测手机中是否安装了ios/android客户端程序
- 判断浏览器版本是否是ie9以下浏览器,提示升级
- js代码判断浏览器种类IE、FF、Opera、Safari、chrome及版本
- 判断图片等比例缩小
- js/jquery判断浏览器的方法小结
- 按比例缩放图片
- js判断浏览器类型及版本
- js判断浏览器与版本号
- 浏览器Chrome对WebGL支持判断
- 1.js判断浏览器版本或类型
- JS 判断浏览器类型 和 JS里面有window.onload 是发生的冲突!
- (转)判断浏览器的js代码