等到文档全部加载完,才执行window.onload內的函数
Code
1 <table id="tbEdit">
2 ……
3 </table>
4 <div id="divFill" style="height:260px"></div>
5 <script type="text/javascript">
6 window.onload = function()
7 {
8 document.getElementById('divFill').style.height = (500 - document.getElementById('tbEdit').offsetHeight) +"px";
9 alert("inner:"+document.getElementById('divFill').style.height);
10 }
11 alert("outer:"+document.getElementById('divFill').style.height);
12 </script>
1 <table id="tbEdit">
2 ……
3 </table>
4 <div id="divFill" style="height:260px"></div>
5 <script type="text/javascript">
6 window.onload = function()
7 {
8 document.getElementById('divFill').style.height = (500 - document.getElementById('tbEdit').offsetHeight) +"px";
9 alert("inner:"+document.getElementById('divFill').style.height);
10 }
11 alert("outer:"+document.getElementById('divFill').style.height);
12 </script>