怎么判断用户是电脑,手机浏览器,还是微信端访问网站

如题所述

第1个回答  2018-03-16

解决方法如下:

1、使用JavaScript脚本可以正确判断浏览器额度类型的

2、相关的代码逻辑如下;

 if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {  //判断iPhone|iPad|iPod|iOS  
    //alert(navigator.userAgent);    
  //  window.location.href ="iPhone.html";  
  console.log("ios");  
} else if (/(Android)/i.test(navigator.userAgent)) {   //判断Android  
    //alert(navigator.userAgent);   
  //  window.location.href ="Android.html";  
   console.log("android");  
    
} else {  //pc  
   // window.location.href ="pc.html";  
     console.log("web");  
      
};

本回答被网友采纳
相似回答