六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 495|回复: 0

用JavaScript把页脚(footer)放到页面底部

[复制链接]

升级  16.8%

178

主题

178

主题

178

主题

进士

Rank: 4

积分
584
 楼主| 发表于 2013-2-8 01:08:26 | 显示全部楼层 |阅读模式
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><style type="text/css" >body{    margin:0px auto;    padding:0px 0px;}</style><title>页脚</title></head><body>abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br />abc<br /><div id="lyfooter" style="position:absolute;height:20px;text-align:center;width:100%;margin:0px 0px;padding:0px 0px;">© 2005 ABCDE, Inc.</div><script language="javascript"><!--function moveFooter() {    var iBottom = 0;//alert('ok');    if (document.all) {cHeight=document.compatMode =="CSS1Compat"?document.documentElement.clientHeight:document.body.clientHeight;sHeight=document.compatMode =="CSS1Compat"?document.documentElement.scrollHeight:document.body.scrollHeight;         if (parseInt(sHeight) > parseInt(cHeight)) {            iBottom = parseInt(sHeight);        }        else iBottom = parseInt(cHeight);        document.all["lyfooter"].style.pixelTop = iBottom - parseInt(document.all["lyfooter"].style.height);    }    else if (document.getElementById) { //NS6        if (document.height > self.innerHeight) {            iBottom = document.height;        }           else iBottom = self.innerHeight;                           document.getElementById("lyfooter").style.top = (parseInt(iBottom - parseInt(document.getElementById("lyfooter").style.height))) + "px";           }   }moveFooter();window.onresize=moveFooter;//--></script></body></html>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表