Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect zoom level on all modern browsers

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?

like image 727
user3098549 Avatar asked Feb 23 '15 14:02

user3098549


1 Answers

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.

like image 69
ctron Avatar answered Sep 22 '22 11:09

ctron