JavaScript重置移动视口缩放级别

发布于 2025-02-13 12:55:42 字数 336 浏览 1 评论 0原文

我有一个网站,移动用户经常放大非常意图的照片。但是,当访问某些链接或特定的JavaScript事件发生时,我需要重置缩放。专门针对移动野生动物园。

请注意:

  • 读取meta [name =“ viewport”]的各种解决方案,然后设置其内容被移动Safari忽略。也许几年前起作用,但现在没有。

到目前为止,我拥有的最好的想法是为链接工作,将它们全部指向另一个域(确实重置视口),然后将该域立即重定向到我的站点。我将实际的预期URL作为获取参数。我测试了它,它起作用了,但是却是。它也只有对链接的帮助,我希望能够为没有导航的JavaScript事件做到这一点。

I have a site where mobile users often zoom in on photos which is very much intended. However, I have a need to reset the zoom when certain links are accessed or specific javascript events fire. Specifically targeting mobile Safari.

Please note:

  • Various solutions to read meta[name="viewport"] and then set its content are ignored by mobile Safari. Maybe that worked years ago, but it doesn't now.

The best idea I've have so far that works for links is to point them all to a different domain (which does reset the viewport) and then have that domain instantly redirect back to my site. I'd pass the actual intended URL as a GET param. I tested it and it works, but sheesh. It also only helps for links, I want to be able to do it for javascript events where there is no navigation taking place.

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

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

发布评论

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