Can I Detect a User’s Page Zoom Level in Browsers?

0
1
Asked By CuriousCoder88 On

I'm curious if there's a way to detect the page zoom level that users set in their browsers when they revisit my website. For instance, when a user first visits, they set the zoom level to 75%. If they close the site and come back later, I want to know if the page zoom is still at 75%. Is there a method to capture this information?

3 Answers

Answered By ResponsiveRanger On

Honestly, trying to manage page zoom sounds like a recipe for complications. There's lots of variables that can affect how things display. I'd suggest focusing on making your site responsive instead.

Answered By TechWhiz42 On

Unfortunately, you can't directly detect the page zoom level in most browsers. Once a user sets the zoom, the browser maintains this preference, but there’s no native way to retrieve that percentage on subsequent visits.

Answered By DesignGuru7 On

I think it's interesting that you want this feature! I can see the use case. If your chart needs to adapt based on zoom, that's important. Just a heads-up though, my method of storing the `devicePixelRatio` in `localStorage` on the first visit doesn’t work for Safari. It doesn’t change when the zoom changes. You might need to explore other strategies for handling your chart's height.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.