jQuery 获取屏幕高度、宽度

来源:互联网 发布:kiki camarena 知乎 编辑:程序博客网 时间:2024/04/25 07:48
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 
 
//获取高度并且赋值//浏览器当前窗口可视区域高度btmHeight = $(window).height();$("#mains").attr("style", "min-height:" + btmHeight + "px;");
0 0