How can I detect the page zoom level in all modern browsers? While this thread tells how to do it in IE7 and IE8, I can\'t find a good cross-browser solution.
>
This has worked great for me in webkit-based browsers (Chrome, Safari):
function isZoomed() {
var width, mediaQuery;
width = document.body.clientWidth;
mediaQuery = '(max-width: ' + width + 'px) and (min-width: ' + width + 'px)';
return !window.matchMedia(mediaQuery).matches;
}
Doesn't seem to work in Firefox though.
This also works in WebKit:
var zoomLevel = document.width / document.body.clientWidth;