scrollHeight
和scrollWidth
,获取网页内容高度和宽度。
一、针对IE、Opera:
scrollHeight
是网页内容实际高度,可以小于clientHeight
。
二、针对NS、FF:
scrollHeight
是网页内容高度,不过最小值是clientHeight
。也就是说网页内容实际高度小于clientHeight
时,scrollHeight
返回clientHeight
。
三、浏览器兼容性
var w=document.documentElement.scrollWidth
|| document.body.scrollWidth;
var h=document.documentElement.scrollHeight
|| document.body.scrollHeight;
注意:区分大小写
scrollHeight
和scrollWidth
还可获取Dom
元素中内容实际占用的高度和宽度。