如何控制 Android/iPhone Web 应用程序的屏幕方向
我正在为智能手机、Android 设备和 iPhone 创建网络应用程序。但我在想,如果网络应用程序只允许纵向屏幕方向会更好,这样无论用户以哪种方式握住手机,它都会始终保持纵向。
所以基本上我想知道的是如何使用 JavaScript、HTML 元标签、CSS 或 PHP 让 Android 和 iPhone 的屏幕始终保持纵向?
I am in the middle of creating a web app for smartphones, Android devices and iPhone's. But I was thinking that it would be better if the web app only allowed a portrait screen-orientation, so no matter which way the user is holding their phone it will always remain in portrait.
So basically what I want to know is how can I have the screen always remain in portrait for both Android and iPhone, using JavaScript, HTML Meta Tags, CSS, or PHP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以读取窗口对象的“大小”、“宽度”,有时还可以读取“方向”属性。设置事件侦听器以在“调整大小”事件发生时触发 JavaScript 事件。
但据我所知,您实际上无法控制旋转。
这是一个演示:(我将其发布到我的网页,http://douglassims.org/rotation.html)
You can read the "size", "width", and sometimes the "orientation" properties of the window object. Set an event listener to fire a javascript event when the "resize" event happens.
As far as I know, though, you can't actually control the rotation.
Here's a demo: (I posted it to my web page, http://douglassims.org/rotation.html)