简体   繁体   English

如何使用 js/jquery 在 IE5 中获得缩放级别?

[英]How to get zoom level in IE5 using js/jquery?

I'm using IE11 and using emulation in developer tool to change document mode to 5. Now I want to get current zoom level, I change it in setting of IE.我正在使用 IE11 并在开发人员工具中使用仿真将文档模式更改为 5。现在我想获得当前的缩放级别,我在 IE 的设置中更改它。

ie5设置

I'm using this code to get zoom level我正在使用此代码来获取缩放级别

zoom = document.documentElement.offsetWidth / $(document).width();

But it only get zoom out (zoom level <= 100%).但它只会缩小(缩放级别 <= 100%)。 If zoom level > 100%, zoom = 1 .如果缩放级别 > 100%,则zoom = 1

there is a library for this: https://github.com/tombigel/detect-zoom有一个库: https://github.com/tombigel/detect-zoom

Unfortunately, it does not work well currently in Desktop browsers.不幸的是,它目前在桌面浏览器中效果不佳。 But if you look at the code it might help.但是,如果您查看代码,它可能会有所帮助。

The short version is that right now this is very difficult.简短的版本是,现在这非常困难。 Why are you trying to detect zoom?你为什么要检测缩放?

I found this code in this library seem works for me https://github.com/tombigel/detect-zoom .我发现这个库中的这段代码似乎对我有用 https://github.com/tombigel/detect-zoom

var zoom = Math.round((screen.deviceXDPI / screen.logicalXDPI) * 100) / 100;

Thanks Rampant for let me know about this library.感谢 Rampant 让我知道这个库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM