在網頁的底部總是保留著公司的版本資訊,如何是這部分資訊來實現呢?下面的一段javascript示範了如何讓footer總是停留在頁面的底部。這段代碼我在實際使用的時候不是特別的完美,在包含有其他javascript控制的頁面和控制項的時候會出現重疊的現象,這是因為沒有對頁面的Body進行onresize和onload操作,希望大家看後有解決的方法)
<HTML>
<HEAD>
<title>讓footer總是停留在頁面的底部</title>
<script language="javascript">
<!--
function moveFooter() {
var iBottom = 0;
if (document.all) {
if (parseInt(document.body.scrollHeight) > parseInt(document.body.clientHeight)) {
iBottom = parseInt(document.body.scrollHeight);
}
else iBottom = parseInt(document.body.clientHeight);
document.all["lyfooter"].style.pixelTop = iBottom - parseInt(document.all["lyfooter"].style.height);
document.all["lyfooter"].style.visibility = "visible";
}
else if (document.layers) {
if (document.height > self.innerHeight) {
iBottom = document.height;
}
else iBottom = self.innerHeight;
document.layers["lyfooter"].top = parseInt(iBottom - document.layers["lyfooter"].document.height);
document.layers["lyfooter"].visibility = "visible";
}
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";
document.getElementById("lyfooter").style.visibility = "visible";
}
}
//-->
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" onresize="moveFooter()" onload="moveFooter()">
<form id="Form1" method="post">
<!----bottom part--------->
<div id="lyfooter" style="position:absolute;left:0px;top:100px;height:19px;z-index:2;visibility:hidden;">
<table border="0" width="100%" cellspacing="0" cellpadding="3">
<tr>
<td width="100%" bgColor="#319a63" class="footnote"><font color="#ffffff" size="2px" face="Verdana, Arial, Helvetica, sans-serif">©
2005 ABCDE, Inc.</font></td>
</tr>
</table>
</div>
<!----/bottom part--------->
</form>
</body>
</HTML>