判断手机电脑

window.onload = function () {
var u = navigator.userAgent;
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {//安卓手机
alert("安卓手机");
// window.location.href = "mobile/index.html";
} else if (u.indexOf('iPhone') > -1) {//苹果手机
// window.location.href = "mobile/index.html";
alert("苹果手机 -"+u);
} else if (u.indexOf('Windows Phone') > -1) {//winphone手机
alert("winphone手机");
// window.location.href = "mobile/index.html";
} else if (u.indexOf('MeeGo') > -1){
alert("MeeGo手机");
} else{
alert(u+"pc");
}
}

posted @ 2015-12-11 18:53  网络爱上点击  阅读(214)  评论(0编辑  收藏  举报