[JavaScript]让footer总是停留在页面的底部(footer all the way at the bottom of the page)
2005-11-24 16:53
585 查看
在网页的底部总是保留着公司的版本信息,如何是这部分信息来实现呢?下面的一段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>
<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>
相关文章推荐
- Keep your footer show at the bottom of the page
- css footer not displaying at the bottom of the page
- JavaScript无提示关闭当前页面窗口,兼容IE/Firefox/Chrome (Close the current page window without confirm by JavaScript, support all browsers)
- JavaScript无提示关闭当前页面窗口,兼容IE/Firefox/Chrome (Close the current page window without confirm by JavaScript, support all browsers)
- 当主页面关闭时关闭所有子窗口(Close all the child windows on unload of main page)
- 当主页面关闭时关闭所有子窗口(Close all the child windows on unload of main page)
- -foot-at-bottom-of-the-page
- Q 4.4 creates a linked list of all the nodes at each depth
- The issue of vertical lines throughing the Report footer or the whole page in Crystal report 11
- Search Engine Optimization - Moving View State to the bottom of the page
- Customize UINavigationBar and remove drop shadow at the bottom of UINavigationBar
- This page contains the following errors: error on line 1 at column 1: Extra content at the end of t
- 【原】用使用JavaScript展开/折叠TreeView中所有节点(Expand and Collapse All Nodes of asp.net Treeview on the client with javascript)
- Javascript Object Method Properties console.log View all methods and properties of the object
- 在写引导页面时,出现Application windows are expected to have a root view controller at the end of application
- Put a Submit Button At the Bottom of a Survey
- FWNX-creates a linked list of all the nodes at each depth-JAVA VERSION
- 使用JavaScript展开/折叠TreeView中所有节点(Expand and Collapse All Nodes of asp.net Treeview on the client with javascript)
- [CrackCode] 4.4 Creates a linked list of all the nodes at each depth of a given tree
- [android引用他人包出现的错误]All versions of the libraries must be the same at this time.以及It is indirectly re