判断是手机还是PC端访问

/*判断手机*/
//判断是手机浏览还是pc
//平台、设备和操作系统 
var system = { 
win: false, 
mac: false, 
xll: false, 
ipad: false 
}; 
//检测平台 
var p = navigator.platform; 
system.win = p.indexOf("Win") == 0; 
system.mac = p.indexOf("Mac") == 0; 
system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); 
system.ipad = (navigator.userAgent.match(/iPad/i) != null) ? true : false; 

if (system.win || system.mac || system.xll || system.ipad) { 

} else { 

var ua = navigator.userAgent.toLowerCase(); 
if(ua.match(/MicroMessenger/i)=="micromessenger") { 
//微信中显示
$("#vedioCon").css("height","320px");
} else { 

var ua = navigator.userAgent.toLowerCase(); 
if(ua.match(/MicroMessenger/i)=="micromessenger") { 
//微信中显示
$("#vedioCon").css("height","320px");
} else { 
// 手机浏览器
$("#vedioCon").css("height","320px");
} 
} 
}

 

posted @ 2016-12-09 11:15  沉着前进  阅读(606)  评论(0编辑  收藏  举报