js判断浏览器客户端类型

 1 if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
 2  
 3     //alert(navigator.userAgent);  
 4     window.location.href ="iPhone.html";
 5  
 6 } else if (/(Android)/i.test(navigator.userAgent)) {
 7  
 8     //alert(navigator.userAgent); 
 9     window.location.href ="Android.html";
10  
11 } else {
12  
13     window.location.href ="pc.html";
14  
15 };
16 
17 if(/(iPhone|iOS|Android|Windows Phone)/i.test(navigator.userAgent)){
18     window.location.href = 'mobile.html';
19 }
1 var ua = navigator.userAgent.toLowerCase();
2 var drive;
3  if (/iphone|ipad|ipod/.test(ua)) {
4       drive = 1;
5   } else if (/android/.test(ua)) {
6       drive = 3;
7     } 

 

posted @ 2019-06-26 23:54  疏影横斜水清浅  阅读(353)  评论(0编辑  收藏  举报