关键词搜索

源码搜索 ×
×

js获取页面缩放比例

发布2020-01-07浏览2030次

详情内容

  1. //获取当前页面的缩放值
  2. function detectZoom() {
  3. var ratio = 0,
  4. screen = window.screen,
  5. ua = navigator.userAgent.toLowerCase();
  6. if (window.devicePixelRatio !== undefined) {
  7. ratio = window.devicePixelRatio;
  8. }
  9. else if (~ua.indexOf('msie')) {
  10. if (screen.deviceXDPI && screen.logicalXDPI) {
  11. ratio = screen.deviceXDPI / screen.logicalXDPI;
  12. }
  13. }
  14. else if (window.outerWidth !== undefined && window.innerWidth !== undefined) {
  15. ratio = window.outerWidth / window.innerWidth;
  16. }
  17. if (ratio) {
  18. ratio = Math.round(ratio * 100);
  19. }
  20. return ratio;
  21. }

 

相关技术文章

点击QQ咨询
开通会员
返回顶部
×
微信扫码支付
微信扫码支付
确定支付下载
请使用微信描二维码支付
×

提示信息

×

选择支付方式

  • 微信支付
  • 支付宝付款
确定支付下载