I have a <div>
element that contains a table, which I want to resize to the maximum viewport height - 70 px. The reason is that I want the header to stay in one place, and the table to scroll independantly. I can't use iframes for that, since there is complicated javascript interacting with the table. I therefore have to use a <div>
and set it's overflow value to scroll. My problem is that the container wont resize when I tell it to. The container looks like this:
<div class="tableContainer" id="tblCont">
<table width="100%" border="0" cellpadding="0" cellspacing="0" id="mainTbl" class="mainTable">
<tr class="row_a" id="1">
<td>id: 1</td>
</tr>
</table>
</div>
The CSS for my tableContainer class is as follow:
.tableContainer
{
overflow: scroll;
/*height: 400px; -- this was just to see if the concept works - and this seems to work fine */
}
Lastly, here is the javascript that is supposed to set the height of the table container:
<script type="text/javascript">
var tbc = document.getElementById("tblCont");
var h = Math.round((window.innerHeight)-(70))+"px";
tbc.style.height = h;
</script>
I even tried setting a fixed height with
tbc.style.height = "50px";
but that also does not work.
Any ideas?