Forum Moderators: open
For example:
----------------------------------------------+
Something
My div
Something
----------------------------------------------+
Ideally, the whole content is displayed with full screen and there is no scrollbars.
I can get the top-left point of 'my div'. If I can get the height of all the elements below it, I can adjust its height to (screenheight - mytop - belowheight).
One possible way is to find the whole height of the document, without the empty spaces(if the document is only part of the screen). But I don't known how to. document.body.offsetHeight/ document.documentElement.offsetHeight seems to return the whole height of the screen while I only need part of them on IE.
Any ideas?
<div id="1">
Something
</div><div id="2">
My div
</div><div id="3">
Something
</div><script type="text/javascript">
// get total height
var totalHeight = document.body.offsetHeight;
// get height of top and bottom div
var topDivHeight = document.getElementById('1').offsetHeight;
var bottomDivHeight = document.getElementById('3').offsetHeight;
// calculate height for center div and apply it
var centerDivHeight = totalHeight - topDivHeight - bottomDivHeight;
document.getElementById('2').style.height = centerDivHeight + 'px';
</script>
[edited by: Trace at 4:19 pm (utc) on July 18, 2007]