
September 8th, 2007, 09:34 PM
|
|
Registered User
|
|
Join Date: Sep 2007
Posts: 1
Time spent in forums: 59 m 52 sec
Reputation Power: 0
|
|
|
Need Help Debugging Script/Error in Script - Buggy Footer function setFooter(fid)
Can somebody help me debug this page. I'm a newbee to the forum. Thanks in advance.
Here is the footer that is offset within the window of the web page.
The page is a two column layout with CSS and JavaScript.
Each side needs to re-position each time window is resized.
I am pretty sure that it may be halfway finished, because the left side will work well.
But my problem is with the right side not dropping below the left
footer on a resize and keeping that pinned to the right.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
>
<html xmlns="" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
<!--
function getWindowHeight() {
var windowHeight = 0;
if (typeof(window.innerHeight) == 'number') {
windowHeight = window.innerHeight;
}
else {
if (document.documentElement && document.documentElement.clientHeight) {
windowHeight = document.documentElement.clientHeight;
}
else {
if (document.body && document.body.clientHeight) {
windowHeight = document.body.clientHeight;
}
}
}
return windowHeight;
}
function setFooter(fid) {
if (document.getElementById) {
var windowHeight = getWindowHeight();
if (windowHeight > 0) {
var contentHeight = document.getElementById('container').offsetHeight;
var footerElement = document.getElementById(fid);
var footerHeight = footerElement.offsetHeight;
if (windowHeight - (contentHeight + footerHeight) >= 0) {
footerElement.style.position = 'absolute';
footerElement.style.top = (windowHeight - footerHeight) + 'px';
}
else {
footerElement.style.position = 'static';
}
}
}
}
window.onload = function() {
setFooter('footer');
}
window.onresize = function() {
setFooter('footer');
}
//-->
</script>
<style tyle="text/css">
#header { margin: 0; padding: 0; }
h1 {
width: 320px; height: 140px;
margin: 0; padding: 0;
border-left: 4px solid #000;
}
h2 { font-weight: normal; }
h3, h4 { margin: 0 0 0 17px; padding: 0 0 0 9px; font-size: 11px; }
h5 { margin: 0; padding: 17px 0 0 0; font-size: 26px; }
h6 { margin: 0; padding: 5px 0; line-height: 18px; }
#leftcontent {
margin-right: 300px;
}
#rightcontent {
margin: 0; padding: 0 25px 0 0;
top: 0; right: 0;
width: 250px;
position: absolute;
}
#content { margin: 0; padding: 40px 0; }
#content p {
margin: 0; padding: 5px 0;
font-size: 14px;
font-family: serif;
line-height: 18px;
}
#info {
margin: 0; padding: 0 0 0 17px;
border-left: 4px solid #000;
}
#date {
font-size: 10px;
margin: 0 0 164px 0; padding: 17px;
height: 35px;
border-left: 4px solid #000;
}
#side-info {
font-size: 11px;
height: 315px;
line-height: 14px;
margin: 0; padding: 5px 17px;
border-left: 4px solid #000;
}
a { text-decoration: none; font-weight: bold; }
#footer-left, #footer-right {
font-size: 10px;
color: #999;
border-left: 1px dotted #CC9;
border: 1px solid red;
}
#footer-left {
float:left;
top: 0px;
margin-left: 0px;
width: 240px;
padding: 10px 17px;
background: green;
}
#footer-right {
float:right;
top: 0px;
margin-right: 0px;
width: 250px;
padding: 10px 25px 10px 0px;
background: blue;
}
#footer-right p {
padding-left: 17px;
}
</style>
</head>
<body id="home">
<!-- Start Container -->
<div id="container">
<!-- Start Left Content -->
<div id="leftcontent">
<!-- Start Header -->
<div id="header"><h1>Header 1</h1></div>
<!-- End Header -->
<!-- Start Content -->
<div id="content">
<div id="info">
<h5>page title</h5>
<p>The text contains The text contains The text contains The text contains The text contains The text contains The text contains</p>
<p>The text contains The text contains The text contains The text contains The text contains The text contains The text contains</p>
<p>The text contains The text contains The text contains The text contains The text contains The text contains The text contains</p>
<p>The text contains The text contains The text contains The text contains The text contains The text contains The text contains</p>
<p>The text contains The text contains The text contains The text contains The text contains The text contains The text contains</p>
<p>The text contains The text contains The text contains The text contains The text contains The text contains The text contains</p>
</div>
</div>
<!-- End Content -->
</div>
<!-- End Left Content -->
<!-- Start Right Content -->
<div id="rightcontent">
<div id="side-info">
<h5>Side Title</h5>
<p>The text contains The text contains The text contains The text contains The text contains The text contains The text contains</p>
<p>The text contains The text contains The text contains The text contains The text contains The text contains The text contains</p>
<p>The text contains The text contains The text contains The text contains The text contains The text contains The text contains</p>
<p>The text contains The text contains The text contains The text contains The text contains The text contains The text contains</p>
<p>The text contains The text contains The text contains The text contains The text contains The text contains The text contains</p>
<p>The text contains The text contains The text contains The text contains The text contains The text contains The text contains</p>
</div>
</div>
<!-- End Right Content -->
</div><!-- End Container -->
<!-- Start Footer -->
<div id='footer'>
<div id="footer-left">
<p>© Footer Text Footer Text Footer Text Footer<br />Text Footer Text Footer Text Footer Text Footer Text </p>
</div>
<div id="footer-right">
<p>How do i get this line to<br />aligned with sidebar</p>
</div>
</div>
<!-- End Footer -->
</body>
</html>
|