js 判断页面是在pc端打开还是在移动端打开
2018-03-14 本文已影响21人
花花0825
window.onload = function(){
if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
//移动端打开
// window.location.href = "https://www.baidu.com/";
$("#pc-body").css("display","none");
$("#app").css("display","block");
document.title = 'app';
} else {
//pc端打开
// window.location.href = "http://news.baidu.com/";
$("#pc-body").css("display","block");
$("#app").css("display","none");
document.title = 'pc';
}
}