PDA

View Full Version : HELP tricky DIV height from dynamic content div



nskate
03-31-2008, 02:09 PM
ahhggg

Ok I have a div in an HTML and the contents of that div is dynamic... a script populates the data inside the div.

I NEED to get the height of that div with the dynamic content and there seems to be no way I can get this. Below is my code both HTML and Javascript:

<html>
<body>
<div id="mydiv"> ---- in here data is populated using PHP scripting --- </div>

<script>
div_height = ocument.getElementById('mydiv').offsetHeight ;
</script>

</body>
</html>



I tried to use .offsetHeight, .height, .contentHeight and they ALL return a ZERO. Dont forget that the data inside the <div> is populated dynamically so the height of the div will change. Is there any way to get the height of that div after the data gets populated?

Thank you in advance :)

Nate

pman
03-31-2008, 11:33 PM
Don't know if this is just a typo while you were posting it, but you seem to be missing the "d" from the word "document"


<script>
div_height = document.getElementById('mydiv').offsetHeight ;
</script>

Jas
04-01-2008, 03:39 AM
You might also try an onload event.

<html>
<head>
<script>
function getdivoffset(){
div_height = document.getElementById('mydiv').offsetHeight;
}
</script>
</head>
<body onload="getdivoffset()">
<div id="mydiv"> ---- in here data is populated using PHP scripting --- </div>
</body>
</html>
It could be executing the script before the div finishes loading.

Or it could definitely be the missing "d"