判断是手机还是PC端访问

时间:2022-05-12 19:02:00
/*判断手机*/
//判断是手机浏览还是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");
}
}
}