Topic: document.height cant be 0??? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=23844" title="Pages that link to Topic: document.height cant be 0??? (Page 1 of 1)" rel="nofollow" >Topic: document.height cant be 0??? <span class="small">(Page 1 of 1)</span>\

 
Schitzoboy
Maniac (V) Inmate

From: Yes
Insane since: Feb 2001

IP logged posted posted 10-28-2004 23:51 Edit Quote

I've written this basic javascript to set to divs to the height of my document.

code:
function setRails()  {
docHeight = document.height;
alert(docHeight);
leftRail = document.getElementById("left");
rightRail = document.getElementById("right");
leftRail.style.height = docHeight + "px";
rightRail.style.height = docHeight + "px";
}



its run at onload. However docHeight always equals 0, how come?

Schitzoboy
Maniac (V) Inmate

From: Yes
Insane since: Feb 2001

IP logged posted posted 10-29-2004 02:12 Edit Quote

Ok, I expanded the code a bit and it seems to work wel in both IE and Firefox. If it does err, it errs on the side of caution.

code:
function setRails()  {
docHeightOne = document.documentElement.offsetHeight;
docHeightTwo = document.body.scrollHeight;
if (docHeightOne > docHeightTwo)
docHeight = docHeightOne;
else
docHeight = docHeightTwo;
leftRail = document.getElementById("left");
rightRail = document.getElementById("right");
leftRail.style.height = docHeight + "px";
rightRail.style.height = docHeight + "px";
}



Still, I'm a total novice to the DOM . I don't know why document.height doesn't give me the height of the document directly, and I may still be doin' stuff I shouldn't be doing here.

You can test this code out here: www.shootpool.info/test.html

Comments? Criticisms?



Post Reply
 
Your User Name:
Your Password:
Login Options: Remember Me On This Computer
 
Your Text:
Loading...
Options: Show Signature
Enable Slimies
Enable Linkwords

« BackwardsOnwards »

Show Forum Drop Down Menu