P粉8248896502023-08-21 17:27:07
May work in IE and Chrome, but not in Firefox:
<script> function toggleZoomScreen() { document.body.style.zoom = "80%"; } </script> <img src="example.jpg" alt="example" onclick="toggleZoomScreen()">
P粉0388567252023-08-21 13:12:46
I would say, it's not possible in most browsers, at least without some extra plugins. And anyway, I'd try to avoid relying on browser scaling, since implementations vary (some browsers only scale fonts, others also scale images, etc.). Unless you don't care much about user experience.
If you need more reliable scaling, then consider using JavaScript and CSS to scale the page's fonts and images, or perhaps do the scaling server-side. This solves image and layout scaling issues. Of course, this requires more work.