使用 Javascript 调整浏览器缩放级别

发布于 2024-09-04 13:23:18 字数 522 浏览 3 评论 0原文

在我拥有的 2 帧“rows=”框架集中,如果用户将缩放级别更改为小于我编码的 125% 值,他们将看到帧之间的“死区”。

这个问题:如何在所有现代中检测页面缩放级别browsers? 显示了如何检测浏览器的缩放级别。

是否可以使用 Javascript 调整浏览器的缩放级别,以便防止用户将缩放更改到所需级别之外?

或者我只是忘记了某种默认的编码注意事项? (我已经看到了 CSS 的“缩放”样式,大概可以设置默认缩放级别。)

我还看到了 document.body.style.zoom,所以看来我们可以做类似的事情:

if (zoomLevelChange)
  {document.body.style.zoom= [some calculation]; }

In the 2-frame 'rows=' frameset I have, if a user change of the zoom level to less than the 125% value that I coded for, they will see "dead space" between the frames.

This question: How to detect page zoom level in all modern browsers? shows how to detect the browser's zoom level.

Is it possible to adjust the browser's zoom level using Javascript so I can keep users from changing the zoom outside of the desired levels?

Or have I simply forgotten a default coding consideration of some kind? (I've seen CSS's 'zoom' style, where presumably default zoom levels can be set.)

I am also seeing document.body.style.zoom, so seems we could do something like:

if (zoomLevelChange)
  {document.body.style.zoom= [some calculation]; }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文