offsetHeight, clientHeight与scrollHeight的区别
在网上搜了一下,结论非常笼统,讲 IE从不讲版本,因此自己做了测试并上传结论 。 以下结论皆是在标准模式下测试通过的,没有测试quirk模式。 clientHeight 大部分浏览器对 clientHeight 都没有什么异议,认为是元素可视区域的高度,也就是说元素或窗口中可以看到内容的这个区域的高度,即然是指可看到内容的区域,滚动条不算在内。但要注意padding是算在内。其计算方式为clientHeight = topPadding + bottomPadding+ height - 水平滚动条高度。 offsetHeight 在IE6,IE7,IE8, IE9以及最新的的FF, Chrome中,对于一般元素,都是offsetHeight = padding + height + border = clientHeight + 滚动条 + 边框。 scrollHeight scrollHeight的争议比较大,有些浏览器认为scrollHeight可以小于clientHeight,有些认为scrollHeight至少应该等于clientHeight。但有一点是一样的,就是scrollHeight >= topPadding + bottomPadding + 内容margin box的高度。 在浏览器中的区别在于: IE6、IE7 认为scrollHeight 是内容高度