CSSOM视图模式scrollWidth/scrollHeight属性实例页面
回到相关文章 »代码:
CSS代码:
.box{width:200px; height:180px; margin-top:1em; overflow:auto;}
HTML代码:
<button id="button1">点击弹出下面框框的scrollWidth和scrollHeight</button> <div id="box" class="box"> <img src="//image.zhangxinxu.com/image/study/s/s256/mm1.jpg" width="256" height="191" /> </div>
JS代码:
document.getElementById("button1").onclick = function() { var oBox = document.getElementById("box"); alert("scrollWidth: " + oBox.scrollWidth + ", \r\nscrollHeight: " + oBox.scrollHeight); };