首页 > 移动平台 > 详细

基于jQuery的判断iPad、iPhone、Android是横屏还是竖屏

时间:2014-11-14 10:23:47      阅读:258      评论:0      收藏:0      [点我收藏+]

function orient() {
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竖屏
$("body").attr("class", "portrait");
orientation = ‘portrait‘;
return false;
}
}
//页面加载时调用
$(function(){
orient();
});
//用户变化屏幕方向时调用
$(window).bind( ‘orientationchange‘, function(e){
orient();
});

基于jQuery的判断iPad、iPhone、Android是横屏还是竖屏

原文:http://www.cnblogs.com/Gbeniot/p/4096533.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!