<script>
window.onload = function () {
  alert(document.body.clientHeight);
</script>页面中有个 table 里面的数据是由asp动态生成的(高度有大概2000多px),用上面的代码却得不到相应的高度,只是得到个600多的px

解决方案 »

  1.   

    是抓去的时间有问题吧?window.onload包括后来读取的动态内容吗?
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title>Untitled Document</title>
     <style type="text/css">
      body{margin:0px;height:0px;}
     </style>
     <script type="text/javascript">
      window.onload=function(){
    alert(document.documentElement.scrollHeight );
    }
     </script>
     </head>
     
    <body>
     <div style="height:1000px;"></div>
     </body>
     </html>