Change body size height

7.8k Views Asked by At

Is there any way to change the body height. I tried:

if(document.body.scrollHeight > document.getElementById('DIVBODY').scrollHeight) {
  document.body.scrollHeight = document.getElementById('DIVBODY').scrollHeight
}

But it does not work. I dynamically change my DIVBODY content and I don't want my to be bigger than the div DIVBODY.

body and div:

<body background="images/grey-lines.png" style="overflow-y:scroll" >

<div id="DIVBODY" style="max-width:1102px; margin: auto; width: expression( Math.min(parseInt(this.offsetWidth), 1102) ); height:100%; text-align:center; align:center;
background-image: url(bg/wood-3.jpg) ; background-color:#af7746; background-attachment:fixed;  background-position: top center ; background-repeat: repeat;  border-left: 1px solid black; border-right: 1px solid black; height: auto; min-height: 100%; _height: 100%;">
1

There are 1 best solutions below

2
On

From MDN:

scrollHeight is a read-only property.

You can try element.scrollTop and element.style.height to accomplish what you want