I have two HTML files: index.html and zoomerror.html.
The site only displays properly at a browser zoom level of 80%. Is there a way that I can use Javascript to detect the zoom level non-stop and redirect the page from index.html to zoomerror.html if the browser zoom level changes from 80% to some other level? I could not think of any code to do that.
EDIT: See the answer for details.
I tried to use the window.devicePixelRatio
function for this, but it just caused the page to constantly refresh, even though the zoom level was 80%.
2
Answers
Nevermind, I fixed it. Click here for the site that helped me. Here is the working code, which works better on a real site than a file URL:
To solve your problem, I’ll provide some javascript code that detects the current browser size and what to do next. This code allows the browser to detect resizing and redirect pages accordingly.