if(/android/i.test(navigator.userAgent)){
console.log(“Android”);//Android
}
if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)){
console.log(“iOS”);//iOS
}
}
js判断客户端是PC端还是移动端访问
//方法1
function IsPC(){
var userAgentInfo = navigator.userAgent;
var Agents = new Array(“Android”, “iPhone”, “SymbianOS”, “Windows Phone”, “iPad”, “iPod”);
var flag = true;
for (var v = 0; v < Agents.length; v ) {
if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }
}
return flag;
}
//方法2
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(n