[英]is device orientation enabled javascript html5
I need to find out whether device orientation is locked on iPhone or Android devices. 我需要确定设备方向是否在iPhone或Android设备上锁定。
I can find a way to find out if device orientation is supported but that won't help me when I want to display a message telling the user that my html5 web page needs rototion to landscape and that his device is locked... 我可以找到一种方法来确定是否支持设备方向,但是当我想显示一条消息告诉用户我的html5网页需要旋转才能旋转并且设备已被锁定时,这对我没有帮助...
Its only a partial solution. 它只是部分解决方案。 Sorry.
抱歉。
I would check device window.orientation on page load, if its not landscape, display message to user to change orientation and turn off orientation lock. 我会在页面加载时检查设备window.orientation,如果它不是横向的,则向用户显示消息以更改方向并关闭方向锁定。
Then listen for "devicemotion" event which should fire even if orientation is locked. 然后侦听即使锁定方向也应触发的“ devicemotion”事件。 Then on "devicemotion" check window.orientation again, If window.orientation is landscape then dismiss message.
然后在“ devicemotion”上再次检查window.orientation,如果window.orientation是landscape,则关闭消息。
devicemotion 设备运动
https://developer.mozilla.org/en-US/docs/Web/Events/devicemotion https://developer.mozilla.org/zh-CN/docs/Web/Events/devicemotion
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.