判断手机是安卓还是IOS

2020-01-06  本文已影响0人  张思学
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";
    }
    if(iphone != -1 || ipad != -1){
        equipmentType = "ios";
    }
    return equipmentType;
}

equipmentType返回值为ios代表当前为苹果手机
equipmentType返回值为andriod代表当前为安卓手机
上一篇下一篇

猜你喜欢

热点阅读