js 判断pc与手机

 

var u = navigator.userAgent;
if ((u.indexOf('Mac') > -1 || u.indexOf('Windows') > -1) && (u.indexOf('iPhone')==-1) ){
console.log('这是PC端');
}else {
console.log('这是手机端');
}

 

posted @ 2016-11-29 14:34  程有立  阅读(150)  评论(0编辑  收藏  举报