简体   繁体   English

是否启用了设备方向javascript html5

[英]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.

相关问题 HTML5设备定位 - 可靠的罗盘实现? - HTML5 Device Orientation - reliable compass implementation? 如何使用相位器框架在html5中实现设备方向 - how to implement device orientation in html5 with phaser framework HTML5方向轴跳转 - HTML5 orientation axes jump 有没有一种方法可以检测Javascript / Cordova / HTML5中的设备振动? - Is there a way to detect device vibration in Javascript/Cordova/HTML5? 在iOS设备上使用HTML5画布中的Javascript设置setTimeout的问题 - Issues with setTimeout with Javascript in HTML5 canvas on iOS device HTML5 & javascript - 从支持多台相机的设备上拍照 - HTML5 & javascript - taking pictures from a device supporting multiple cameras HTML5 / Javascript使用devicemotion / deviceorientation计算设备速度 - HTML5/Javascript calculate device speed using devicemotion/deviceorientation Javascript-HTML5音频无法在Android设备上播放 - Javascript - HTML5 audio does not play on Android device 如何使用HTML5 Javascript和Phonegap获取设备信息 - How to get Device Information Using HTML5 Javascript & Phonegap 有没有办法通过Javascript / HTML5从USB设备获取GPS位置? - Is there a way to get a GPS location from a USB device with Javascript/HTML5?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM