Reputation: 1259
I was wondering if there's a way to detect the page zoom level which is supported by all modern browsers. I've already tried this: how-to-detect-page-zoom-level-in-all-modern-browsers
but unfortunately it is not fully compatible with all the browser I tried.
Is there a more general method, or a jquery library to achieve that?
Upvotes: 9
Views: 10897
Reputation: 694
It depends on what your goal. If you only need the current scaling you can use:
window.devicePixelRatio
But the value is not equal to the zoom level on all devices because on HighDPI devices (4k Display, Smartphone, …) the start value is not 1 because there is a default zoom to compensate the higher pixel resolution.
Upvotes: 6