JAVASCRIPT
VUE
REACT
NODE
ES6
TYPESCRIPT

手机端区分安卓和苹果系统

2018. 08. 21    

手机端区分安卓和苹果系统

script:

function detect(){
    var equipmentType = "";
    var agent = navigator.userAgent.toLowerCase();
    var android = agent.indexOf("android");
    var iphone = agent.indexOf("iphone");
    var ipad = agent.indexOf("ipad");
    if(android != -1){
        equipmentType = "android";
  	console.log('安卓')
        
    }
    if(iphone != -1 || ipad != -1){
        equipmentType = "ios";
        console.log('ios')
    }
    return equipmentType;
}
detect()


以上