方法1:

<html>
<head>
    <title></title>
    <script language="javascript" type="text/javascript">
        window.onload = function() {
            var div = document.getElementById("csdn");
            div.style.position = "absolute";
            div.style.top = "0";
            div.style.height = document.documentElement.clientHeight;
        }
  </script>

</head>
<body>
 <div id="csdn" style="background-color: #FF0000; width: 200px;">
  1234567890-=<br />
  1234567890-=<br />
 </div>   
</body>
</html>

 

2. 方法2

方法1在有些场合还是无法解决问题,

var height = document.documentElement.scrollHeight;
                          if (height > 30) {
                              height = height - 30;
                              $("body").css('height', height);
                          }
                      }

 

这里使用了 document.documentElement.scrollHeight

 

相关文章:

  • 2021-07-03
  • 2021-12-26
  • 2021-12-08
  • 2022-12-23
  • 2022-01-03
  • 2021-12-23
  • 2021-12-23
猜你喜欢
  • 2022-01-09
  • 2021-05-20
  • 2021-09-07
  • 2022-02-09
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
相关资源
相似解决方案