用户名: 密   码:
   飞诺网 加入收藏
飞诺网 网页设计 FrontPage Dreamweaver html Javascript css 网页制作技巧 网页特效 色彩原理 设计理念 web技术文档
Javascript系列教程 Javascript实例 Javascript技术文档

您当前的位置:飞诺网 >>  网页设计 >>  Javascript >> Javascript技术文档

JS获取网页高度及屏幕分辨率高度让DIV层始终在页面最底部

www.diybl.com    时间 : 2010-11-18  作者:佚名   编辑:fnw 点击:   [ 评论 ]

用法:将以下代码保存为HTML格式的页面即可。
实现的功能
当页面里内容的高度没有让页面出现滚动条时,页面当前页面的最底部显示。
当出现滚动条后,DIV层会自动向下跟随,在页面的最底部显示。
更改TABLE的高度就可以看到DIV层始终在页面最底部
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>JS获取网页高度及屏幕分辨率高度让DIV层始终在页面最底部</title> 
</head> 
<body leftmargin="0" topmargin="0"> 
<table width="100%" height="405" bgcolor="#eeeeee"> 
    <tr> 
        <td> 
        aaa 
        </td> 
    </tr> 
</table> 
<div id="t1"  style="position:absolute;border:double;"> 
aaaaaaa 
</div> 
<script language="javascript">... 
//document.all.t1.style.top = document.body.clientHeight; 
    var h1 = window.screen.availHeight-165; 
    if (document.body.clientHeight<h1) 
      document.all.t1.style.top = window.screen.availHeight-165; 
    document.write ("当前窗口宽:"+document.body.offsetWidth+"; 高:"+document.body.clientHeight+"aaaa"+(window.screen.availHeight)); 
</script> 
</body> 
</html>
如果图片或页面不能正常显示请点击这里
Javascript技术文档推荐文章

文章评论