判断是否是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();
});
发表回复