In Internet Explorer 7 some properties (mouse coordinates) are treated as physical while others are logical (offset). This essentially required Web developers to be aware of or calculate the zoom state. In IE8 release all properties are logical.
From stackoverflow
-
You can get it using:
var b = document.body.getBoundingClientRect(); alert((b.right - b.left)/document.body.clientWidth);
Thanks a lot @niclasnorgren!
-
Also, if you need to do check in IE 8, you can use window.screen.deviceXDPI and window.screen.deviceYDPI. The default is 96 dpi, and if you're zoomed, the number will be larger (aka 144 when zoomed 150%)
-
There is a small syntax error (body instead of document.body) on the accepted answer. This seems to do the trick also.
var rect = document.body.getBoundingClientRect(); var zoomLevel = Math.round((rect.right-rect.left)/document.body.clientWidth * 100);
0 comments:
Post a Comment