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

如何用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";
};

猜你喜欢

转载自coyotestark.iteye.com/blog/2246113