欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

用JS判断iPhone|iPad|iPod|iOS|Android客户端

程序员文章站 2022-05-27 21:39:22
...

如何用JS判断是苹果客户端还是安卓客户端:

if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
    //alert(navigator.userAgent);  
    window.location.href ="iPhone.html";
} else if (/(Android)/i.test(navigator.userAgent)) {
    //alert(navigator.userAgent); 
    window.location.href ="Android.html";
} else {
    window.location.href ="pc.html";
};

 

相关标签: JS 安卓 苹果