当前位置: 代码迷 >> Web前端 >> 怎么用jQuery做浏览器类型判断和分辨率判断,直接贴代码
  详细解决方案

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

热度:401   发布时间:2012-06-27 14:20:08.0
如何用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

//返回当前页面高度
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; 
} 
}; 
  相关解决方案