是否可以防止“翻转”?通过 JavaScript/jQuery 在 iPhone 网站中?
我只是不想当 iPhone 改变方向时网站也改变方向。
是否可以?
I just don't want the site change orientation when iPhone change orientation.
Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法通过 JavaScript 来阻止这种情况,它是由浏览器控制的……如果您可以这样做,实际上您就会破坏用户的行为期望,这绝不是一件好事。
另外,如果可以的话,用户会处于哪个方向?当他们到达您的网站时,手机可能处于任一方向。
You can't prevent this via JavaScript, it's browser controlled...and really you'd be breaking the user's expectations of behavior if you could do this, which is hardly ever a good thing.
Also if you could, which orientation would the user be in? When they arrived on your site the phone could have been in either orientation.
请参阅此答案,了解如何使用 CSS/JS 在方向更改时旋转渲染的显示。这个想法是捕获方向事件,然后强制显示回到纵向/横向。
如何锁定iPhone Web 应用程序中的纵向模式方向?
See this answer for how to use CSS/JS to rotate the rendered display on orientation change. The idea is to capture the orientation event, and then force the display back to portrait/landscape.
How do I lock the orientation to portrait mode in a iPhone Web Application?