日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

javascript检查移动设备是否支持重力方向感应

發布時間:2023/12/15 javascript 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 javascript检查移动设备是否支持重力方向感应 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
 javascript如何檢查移動設備,如手機平臺是否支持重力或者方向感應。可以使用html5提供的重力和方向感應接口來判斷。html5 中針對高端手機提供了重力感應和重力加速的接口,開發可以利用這個接口獲取到移動設備重力加速感應數據。目前已經支持的瀏覽器只有chrome和firefox,以及IOS的webkit(貌似android上因為版本差異很大,部分低版本的系統不支持)。引用來源:http://www.pjhome.net/article/Javascript/html5_Orientation.html javascript檢查移動設備是否支持重力方向感應源代碼如下-收縮HTML代碼  運行代碼  [如果運行無效果,請自行將源代碼保存為html文件運行] <title>javascript檢查移動設備是否支持重力方向感應</title> <script>var supportDevicemotion=false,supportOrientation=false;function orientationListener(e) {if (e.type == 'devicemotion') {supportDevicemotion = true;window.removeEventListener('devicemotion', orientationListener, false);document.body.appendChild(document.createTextNode('設備支持重力感應|'));}else if (e.type == 'deviceorientation' || e.type.toLowerCase() == 'mozorientation') {supportOrientation = true;window.removeEventListener('deviceorientation', orientationListener, false);window.removeEventListener('MozOrientation', orientationListener, false);document.body.appendChild(document.createTextNode('設備支持方向感應'));}}window.addEventListener('deviceorientation', orientationListener, false); //方向感應器 window.addEventListener('MozOrientation', orientationListener, false); //方向感應器 for firefox window.addEventListener('devicemotion', orientationListener, false); //重力加速感應器 for iphone, android </script>

?

轉載于:https://www.cnblogs.com/yzryc/p/6249349.html

總結

以上是生活随笔為你收集整理的javascript检查移动设备是否支持重力方向感应的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。