日期:2014-05-16  浏览次数:20347 次

如何获取当前可视区域的大小?
我将body中放入一个高度为1000px的div,浏览器会出现滚动条,此时,我想获得当前可视区域的高度,不是整个区域的高度,如何获取?我写了如下代码:

$(function(){
windowHeight = $(window).height();
documentHeight = $(document).height();
console.warn("windowHeight:"+windowHeight+",documentHeight:"+documentHeight);
//windowHeight:1036,documentHeight:1036
});

很显然获取的都是当前整个区域的高度,当不是当前浏览器可视区域的高度,如何获取这个高度?
jQuery height js

------解决方案--------------------
window.innerHeight?
------解决方案--------------------
window.innerHeight