
我知道在iPhone上的Safari中,你可以通过监听onorIEntationchange事件和查询window.orIEntation来检测屏幕的方向和方向的变化.
这可能在Android手机上的浏览器中出现吗?
为了清楚起见,我问的是,在标准网页上运行的JavaScript是否可以检测到AndroID设备的旋转.这可能在iPhone上,我想知道是否可以为AndroID手机完成.
解决方法:
要在AndroID浏览器上检测方向更改,请将侦听器附加到窗口上的orIEntationchange或resize事件:
// Detect whether device supports orIEntationchange event, otherwise fall back to// the resize event.var supportsOrIEntationChange = "onorIEntationchange" in window, orIEntationEvent = supportsOrIEntationChange ? "orIEntationchange" : "resize";window.addEventListener(orIEntationEvent, function() { alert('HolY ROTATING SCREENS BATMAN:' + window.orIEntation + " " + screen.wIDth);}, false);检查window.orIEntation属性以确定设备的方向.使用AndroID手机时,screen.wIDth或screen.height也会随着设备的旋转而更新. (这不是iPhone的情况).
总结以上是内存溢出为你收集整理的使用JavaScript检测浏览器中Android手机的旋转全部内容,希望文章能够帮你解决使用JavaScript检测浏览器中Android手机的旋转所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)