判断设备

 1 <script type="text/javascript">
 2      function detectmob() {
 3                 if( navigator.userAgent.match(/webOS/i)
 4                 || navigator.userAgent.match(/iPad/i)
 5                 || navigator.userAgent.match(/iPod/i)
 6                 || navigator.userAgent.match(/BlackBerry/i)
 7                 || navigator.userAgent.match(/Windows Phone/i)
 8                 ){
 9                     return true;
10                     $("#changeStyle").attr("href","css/gameIndexPad.css");//替换css
11                     document.body.addEventListener('touchmove', function (e) {
12                       e.preventDefault(); //阻止默认的处理方式(阻止下拉滑动的效果)
13                     }, {passive: false}); //passive 参数不能省略,用来兼容ios和android
14                 }
15                 else if(navigator.userAgent.match(/Android/i)
16                 ||navigator.userAgent.match(/iPhone/i)
17                 ){
18                     return false;
19                     
20                 }
21             }
22             //alert(detectmob())
23             detectmob()
24 </script>

 

posted @ 2018-11-08 16:39  微光半夏星  阅读(186)  评论(0编辑  收藏  举报