如何用jQuery做浏览器类型判断和分辨率判断,直接贴代码:

来源:http://itindex.net/blog/2011/12/27/1324977447270.html
如何用jQuery做浏览器类型判断和分辨率判断,直接贴代码:



<SCRIPT type="text/javascript">

var bHeight=$(window).height()-$('.ui-layout-south').height()-$('.ui-layout-north').height();

$("#page").css({height:bHeight+'px'});

$(function() {

if($.browser.msie) {

}

else if($.browser.safari) {//contains chrome

}

else if($.browser.mozilla) {

}

else if($.browser.opera) {

}

else {

//alert("i don't konw!");

}

});





</SCRIPT>

<script type="text/javascript">

$(document).ready(function()

{

//alert($(window).height()); //浏览器当前窗口可视区域高度

//alert($(document).height()); //浏览器当前窗口文档的高度

//alert($(document.body).height());//浏览器当前窗口文档body的高度

//alert($(document.body).outerHeight(true));//浏览器当前窗口文档body的总高度 包括border padding margin

//alert($(window).width()); //浏览器当前窗口可视区域宽度

//alert($(document).width());//浏览器当前窗口文档对象宽度

//alert($(document.body).width());//浏览器当前窗口文档body的高度

//alert($(document.body).outerWidth(true));//浏览器当前窗口文档body的总宽度 包括border padding margin



alert(screen.height);//显示器分辨率,只能用JavaScript代码获取

alert(screen.width);

})

</script>

来源:http://e7show.net/index.php?option=com_content&view=box&vid=20120102165220

[code]//返回当前页面高度
function pageHeight(){
if($.browser.msie){
return document.compatMode == "CSS1Compat"? document.documentElement.clientHeight :
document.body.clientHeight;
}else{
return self.innerHeight;
}
};


//返回当前页面宽度
function pageWidth(){
if($.browser.msie){
return document.compatMode == "CSS1Compat"? document.documentElement.clientWidth :
document.body.clientWidth;
}else{
return self.innerWidth;
}
}; [/code]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值