當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
[JavaScript]让footer总是停留在页面的底部(footer all the way at the bottom of the page)
生活随笔
收集整理的這篇文章主要介紹了
[JavaScript]让footer总是停留在页面的底部(footer all the way at the bottom of the page)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
????? 在網(wǎng)頁的底部總是保留著公司的版本信息,如何是這部分信息來實現(xiàn)呢?下面的一段javascript演示了如何讓footer總是停留在頁面的底部。這段代碼我在實際使用的時候不是特別的完美,在包含有其他javascript控制的頁面和控件的時候會出現(xiàn)重疊的現(xiàn)象,這是因為沒有對頁面的Body進行onresize和onload操作,希望大家看后有解決的方法)
????<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>
轉(zhuǎn)載于:https://www.cnblogs.com/rippleyong/archive/2005/11/24/283739.html
總結(jié)
以上是生活随笔為你收集整理的[JavaScript]让footer总是停留在页面的底部(footer all the way at the bottom of the page)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 楚乔传17、18集 楚乔得知身世
- 下一篇: 公司培训文档-JavaScript[对象