I need to be able to dynamically assign a variable to the height attribute of a div(flashOverlay) based on the height and t position of another div(pageContent). I am using the following script to capture the variable data. How do I apply this var to the div?

<script type="text/javascript">
<!--
onload=function() {

var divh = document.getElementById('pageContent').offsetHeight;

     alert(divh +460+"px");

 }
//-->
</script>

The div I also has the following style applied using external CSS file

#flashOverlay{
    TOP: 0px;
    LEFT: 0px;
    POSITION: absolute;
    Z-INDEX: 20;
    visibility: visible;
    overflow: auto;
    margin: 0px;
    width: 100%;
    padding: 0px;
    vertical-align: top;
    height: 1054px;
}

something like:

<script type="text/javascript">
<!--
onload=function() {

var divh = document.getElementById('pageContent').offsetHeight;
var target = document.getElementById('flashOverlay');
target.style.height = ( divh + 460 ) + "px";
}
//-->
</script>

Worked a treat - thank you!

Hi All,
Neither of the properties clientHeight and offsetHeight has worked out for me while I try to determine the height of the div created dynamically. Could someone suggest alternative please? Thanks a ton in advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.