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
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.
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.
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
Cloudflare Origin SSL Certificate Setup Guide
How To Effectively Monetize A Site With Ads