digdeep

凡是过去,皆是序幕。Read the fucking manual and source code.

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

方法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

 

posted on 2020-03-27 23:28  digdeep  阅读(2158)  评论(0编辑  收藏  举报
不懂数据库和Web安全的架构师不是一个好的程序员。