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

215 Views Asked by At

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.

ie5 setting

I'm using this code to get zoom level

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

But it only get zoom out (zoom level <= 100%). If zoom level > 100%, zoom = 1.

2

There are 2 best solutions below

1
Brenn On

there is a library for this: 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?

3
IFZR On

I found this code in this library seem works for me 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.