0

How to get the zoom level of browser??? I have tried many pattrens

console.log("document:" + $(document).width()); // same
console.log("whole width:" + $(window).width()); //same
console.log("innerWidth:" + $(window).innerWidth()); //same
console.log("outerWidth:" + $(window).outerWidth());  //same
console.log("devicePixelRatio:" + window.devicePixelRatio);

devicePixelRatio looks work but in my chrome browser, it default 2.

I am not sure why this is 2....

whitebear
  • 11,200
  • 24
  • 114
  • 237
  • 1
    [`devicePixelRatio`](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio) is the ratio between a physical pixel and a css pixel. That you're seeing a value of 2 just means you're viewing on a high dpi display, like a retina display. – ray Mar 27 '20 at 06:25
  • https://stackoverflow.com/questions/1713771/how-to-detect-page-zoom-level-in-all-modern-browsers – Teemu Mar 27 '20 at 06:29
  • mmm this is quite complex than I thought.... thank you very much! – whitebear Mar 28 '20 at 18:04

0 Answers0