Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect Zoom in Firefox

I want to detect if the browser is zoomed in or out (don't really care to know the value, but I assume it will need to be found anyway in the decision process). I have read a lot of other SO posts on the topic, but none of the solutions given work on FF (although there is an IE7/8 and chrome solution).

Oh, and I can't use flash, so the flash solution is out of the question.

Edit: And I must be able to detect this on the initial page load

like image 367
Joda Maki Avatar asked Feb 14 '11 14:02

Joda Maki


1 Answers

With modern versions of FireFox, you can now do the following:

DPR = window.devicePixelRatio;
if ( DPR <= 0.999 || DPR >= 1.001 ){
   // User has zoomed in or zoomed out
}
like image 63
Brian Webster Avatar answered Oct 13 '22 02:10

Brian Webster