js让一行页脚保持在底部
时间:2020-10-15 23:16:59|栏目:JavaScript代码|点击: 次
测了一下,还可以,在IE6、IE7、FIREOFX等都没有问题! 窗口缩小时也没有问题!
<script language="JavaScript" type="text/javascript">
function test(){
var infoHeight = document.getElementById("info").scrollHeight;
var bottomHeight = document.getElementById("bottom").scrollHeight;
var allHeight = document.documentElement.clientHeight;
var bottom = document.getElementById("bottom");
if((infoHeight + bottomHeight) < allHeight){
bottom.style.position = "absolute";
bottom.style.bottom = "0";
}else{
bottom.style.position = "";
bottom.style.bottom = "";
}
setTimeout(function(){test();},10);
}
test();
</script>
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
复制代码 代码如下:
<script language="JavaScript" type="text/javascript">
function test(){
var infoHeight = document.getElementById("info").scrollHeight;
var bottomHeight = document.getElementById("bottom").scrollHeight;
var allHeight = document.documentElement.clientHeight;
var bottom = document.getElementById("bottom");
if((infoHeight + bottomHeight) < allHeight){
bottom.style.position = "absolute";
bottom.style.bottom = "0";
}else{
bottom.style.position = "";
bottom.style.bottom = "";
}
setTimeout(function(){test();},10);
}
test();
</script>
[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]
上一篇:JS实现将Asp.Net的DateTime Json类型转换为标准时间的方法
栏 目:JavaScript代码
下一篇:javascript深拷贝(deepClone)详解
本文标题:js让一行页脚保持在底部
本文地址:http://www.codeinn.net/misctech/11885.html