返回列表

判断iphone及android

默认分类 2014/07/16 00:25

原文地址:http://www.fufuok.com/js-iphone-android.html

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