Forum Moderators: open
I have a problem with determining the exact height of div in IE.
The div in CSS looks like this
#main
{
width:200px;
}
I'm referencing it in the following way with JS
....
temp=document.getElementById('main');
alert(temp.currentStyle.height);
.....
alert will simply return the value of "auto", but I need the exact pixel size of the layer as it grows or shrinks, depending on the content size. I have no problem accomplishing this with a similar function in Mozilla, but I can't figure out how to get the pixels in IE.
Thanks for your help
<html>
<head>
<style>
#test{width:150px;height:100px;border: solid 1px gray;}
</style>
<script>window.onload = function()
{
var test = document.getElementById("test");
alert("before: "+ test.offsetHeight);
test.innerHTML = "Blah blah blah blah blah blah blah "
+ "blah blah blah blah blah blah blah "
+ "blah blah blah blah blah blah blah ";
alert("after: "+ test.offsetHeight);
}
</script>
</Head>
<body>
<div id="test">
</div>
</Body>
</HTML>[/pre]
Testing the local style object won't give the actual height, if the element has been stretched by content.