判断是否是 PC 端
if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {// 挪动端}else{//PC}
判断是否横屏
function orient() {console.log($(window).width())
$('.back-box').css('display','none')
if (window.orientation == 90 || window.orientation == -90) {
//ipad、iphone 竖屏;Andriod 横屏
$("body").attr("class", "landscape");
orientation = 'landscape';
return false;
}
else if (window.orientation == 0 || window.orientation == 180) {
//ipad、iphone 横屏;Andriod 竖屏
if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {// 挪动端}else{//PC}
$("body").attr("class", "portrait");
orientation = 'portrait';
return false;
}
}
// 页面加载时调用
$(function(){orient();
});
// 用户变动屏幕方向时调用
$(window).bind('orientationchange', function(e){orient();
});