'Detect OS zoom in browser
I have an iframe with a certain height and width. Based on the browser and OS zoom level, I want to change the dimensions of the iframe.
My question is: How do I detect the OS zoom. I do know how to get the browser level zoom based on the answer How to detect page zoom level in all modern browsers?, but as I change the OS zoom (on windows and MAC), the browser zoom returned is the same. So I want to compensate for the browser zoom, and that is the reason I am looking to find a way to determine the OS level zoom.
I am interested in a solution for Chrome and Safari for now. Thank you for your help.
Solution 1:[1]
Just use vw and vh CSS units to set size of the iframe.
Solution 2:[2]
You can get OS zoom level from window.devicePixelRatio
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | kirilloid |
| Solution 2 | ixpl0 |
