style.height:包括 元素的滚动条,不包括边框
clientHeight:不包括元素的滚动条和边框
offsetHeight:包括元素的滚动条和边框
scrollHeight :offsetHeight+scrollTop
公式是:
style.height=clientHeight+滚动条宽度;
offsetHeight=style.height+borderTop+borderBottom;
scrollHeight=offsetHeight+scrollTop;
同理: clientWidth,offsetWidth,style.width,scrollWidth
例。
<div id="eyejs" style="border: solid 10px red;width:100px;height:100px;overflow:scroll;">
<div style="height:200px;"></div>
</div>
<input type="button" onclick="alert(document.getElementById('eyejs').clientHeight)" value="点击clientHeight" />
<input type="button" onclick="alert(document.getElementById('eyejs').style.height)" value="点击style.height" />
<input type="button" onclick="alert(document.getElementById('eyejs').offsetHeight)" value="点击offsetHeight" />
<input type="button" onclick="alert(document.getElementById('eyejs').scrollHeight)" value="点击scrollHeight" />
本文来自:http://www.cnblogs.com/tianguook/archive/2011/02/28/1967481.html