JavaScriptでフッターをページの下に置く
2437 ワード
<!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>