scrollWidth 예제
<style> #box { height: 250px; width: 250px; overflow: auto; } #content { height: 1000px; width:750px ; padding: 50px; background-color: tomato; } </style> <button onclick="homzzang()">클릭</button> <div id="box"> <div id="content">홈짱닷컴 Homzzang.com</div> </div> <p id="demo"></p> <script> function homzzang() { var content = document.getElementById("content"); var y = content.scrollHeight; var x = content.scrollWidth; document.getElementById ("demo").innerHTML = "Height: " + y + "px<br>Width: " + x + "px"; } </script> 결과보기
<style>
#box {
height: 250px;
width: 250px;
overflow: auto;
}
#content {
height: 1000px;
width:750px ;
padding: 50px;
background-color: tomato;
</style>
<button onclick="homzzang()">클릭</button>
<div id="box">
<div id="content">홈짱닷컴 Homzzang.com</div>
</div>
<p id="demo"></p>
<script>
function homzzang() {
var content = document.getElementById("content");
var y = content.scrollHeight;
var x = content.scrollWidth;
document.getElementById ("demo").innerHTML = "Height: " + y + "px<br>Width: " + x + "px";
</script>
결과보기