9

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?

user3098549
  • 981
  • 1
  • 12
  • 24
  • Did you had any luck? – jason Jul 16 '15 at 00:52
  • 1
    Possible duplicate of [How to detect page zoom level in all modern browsers?](https://stackoverflow.com/questions/1713771/how-to-detect-page-zoom-level-in-all-modern-browsers) – ZachB Oct 19 '18 at 23:23

1 Answers1

5

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.

ctron
  • 674
  • 9
  • 15