美文网首页
判断手机是安卓还是IOS

判断手机是安卓还是IOS

作者: 张思学 | 来源:发表于2020-01-06 13:42 被阅读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代表当前为安卓手机

相关文章

网友评论

      本文标题:判断手机是安卓还是IOS

      本文链接:https://www.haomeiwen.com/subject/sxckactx.html