web-app h5 区分安卓与ios和pc

前沿

之前一直在开发web-app,期间遇到了很多坑,也是一步一步的趟坑趟过来的,所以需要记录下来,之前一直是存在笔记里,发现好久不用也就忘记了,现在贴出来,有助于共同学习。

通过navigator来区分安卓和ios,亲测可用,项目中使用过

if (/(iPhone|iPad|iPod|iOS)/S)/i.test(nav(st(navigator.userAgerAgent)) {  //判断iPhone|iPad|iPod|iOS
    //alert(rt(navigator.userAgerAgent); 
       window.location.href ="i =" ="iPhone.html";
}";
} else if (/(Android)/d)/i.test(nav(st(navigator.userAgerAgent)) {   //判断Android
    //alert(rt(navigator.userAgerAgent); 
       window.location.href ="A =" ="Android.html";
}";
} else {  //pc
       window.location.href ="p =" ="pc.html";
}";
};

你可能感兴趣的:(web-app h5 区分安卓与ios和pc)