码迷,mamicode.com
首页 > Web开发 > 详细

JS客户端判断

时间:2016-05-26 18:27:02      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:

<script language="javascript" type="text/javascript">

        function browserDetection(){

              var userAgent=window.navigator.userAgent.toLowerCase();

              var browser=null;

              if(userAgent.match(/ipad/i)){browser=‘ipad‘;

              }else if(userAgent.match(/iphone os/i)){browser=‘iphone‘;

              }else if(userAgent.match(/midp/i)){browser=‘midp‘   

              }else if(userAgent.match(/rv:1.2.3.4/i)){browser=‘rv:1.2.3.4‘;

              }else if(userAgent.match(/ucweb/i)){browser=‘ucweb‘;

              }else if(userAgent.match(/android/i)){browser=‘android‘;

              }else if(userAgent.match(/windows ce/i)){browser=‘windowsCe‘;

              }else if(userAgent.match(/windows mobile/i)){browser=‘windowsMobile‘; 

              }else{browser=‘PC‘ 

              }

              return browser;

       }

if(browserDetection()!="PC"){alert("不是PC端")

}else{alert("是PC端")}

</script>

JS客户端判断

标签:

原文地址:http://www.cnblogs.com/ranyonsue/p/5532049.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!