第一种:通过判断浏览器的userAgent,用正则来判断是否是ios和Android客户端。
代码如下:
第二种:检查是否是移动端(Mobile)、ipad、iphone、微信、QQ等。
使用方法:
//判断是否IE内核
if(browser.versions.trident){ alert(“is IE”); }
//判断是否webKit内核
if(browser.versions.webKit){ alert(“is webKit”); }
//判断是否移动端
if(browser.versions.mobile||browser.versions.android||browser.versions.ios){ alert(“移动端”); }
检测浏览器语言
currentLang = navigator.language; //判断除IE外其他浏览器使用语言
if(!currentLang){//判断IE浏览器使用语言
currentLang = navigator.browserLanguage;
}
alert(currentLang);
第三种:判断iPhone|iPad|iPod|iOS|Android客户端,来自http://www.fufuok.com/JS-iphone-android.html
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { //判断iPhone|iPad|iPod|iOS
//alert(navigator.userAgent);
window.location.href ="iPhone.html";
} else if (/(Android)/i.test(navigator.userAgent)) { //判断Android
//alert(navigator.userAgent);
window.location.href ="Android.html";
} else { //pc
window.location.href ="pc.html";
};
第四种:判断pc还是移动端
以上所述是小编给大家介绍的JS判断Android、iOS或浏览器的多种方法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对考高分网网站的支持!



