iPad/iPhone 方向改变时强制缩放

发布于 2024-12-24 20:55:09 字数 457 浏览 3 评论 0原文

我正在开发一个由我以外的人设计和编码的网站。这样做并没有考虑到 iPad 和 iPhone。该项目现在已经找到了适合我的方式,我已经能够使该网站在大多数情况下在两种设备上都能很好地显示。

我遇到问题的部分是方向变化时的缩放。我已经尝试了本网站和其他网站上建议的几乎所有修复方法,但没有一个有效。基本上,当您以纵向或横向加载网站时,它会自动缩放以适应视图。这是使用默认行为,因为我当前没有在视口元中设置最大/最小比例尺寸。

当方向发生变化时,网站似乎无法缩放。但是,如果我单击链接,页面将重新加载并缩放到正确的大小。我试图在方向改变时模仿同样的行为。我尝试使用 onorientationchange 事件在 JavaScript 中触发页面重新加载,但没有成功。页面会重新加载,但不会缩放。仅当单击链接时才会发生缩放。

我缺少什么?有没有办法强制在方向改变时进行缩放,就像单击链接时一样?单击导致缩放的链接时是否会触发事件?我很感激你能给我的任何帮助。

I am working on a site that was designed and coded by someone other than myself. It was not done with the iPad and iPhone in mind. The project has now found its way to me and I've been able to make the site display well on both devices for the most part.

The part I am having trouble with is scaling on orientation change. I've tried almost all of the fixes suggested on this site and others, but none of them have worked. Basically when you load the site in either portrait or landscape it auto scales to fit in the view. This is using default behavior as I don't currently have a max/min scale size set in viewport meta.

When an orientation changes occurs, the site seems to not scale though. However, if I click a link the page will reload and scale to the correct size. I am trying to mimic this same behavior on orientation change. I have tried firing a page reload in JavaScript using the onorientationchange event, but no go. The page reloads, but does not scale. The scaling only happens when a link is clicked.

What am I missing? Is there a way to force the scaling to happen upon orientation change the same way it does when clicking a link? Is there an event that fires when a link is clicked that causes the scaling? I appreciate any help you can give me.

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

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

发布评论

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