乐趣区

关于javascript:夏哥事件簿-WEB前端-获取设备

function IsEquipment() {
  var flag = "PC";
  var userAgentInfo = navigator.userAgent;
  var Agents = [
                "Android", 
                "iPhone", 
                "SymbianOS", 
                "Windows Phone", 
                "iPad", 
                "iPod"
                ];
  
  for (var v = 0; v < Agents.length; v++) {if (userAgentInfo.indexOf(Agents[v]) > 0) {
      flag = "Mobile";
      break;
    }
  }
  return flag;
}; 

获取以后设施,PC—电脑,Mobile—挪动端。

退出移动版