Forum Moderators: open

Message Too Old, No Replies

is there a tag for body Height

         

rcjordan

11:46 pm on Jan 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In dhtml coding, the width of the browser window height in ns4 and ns6 is referenced as innerHeight. In IE, it's document.body.clientHeight. Are there similar tags for the total page body height?

Eddie Traversa

4:17 am on Jan 6, 2002 (gmt 0)



if you mean also capturing the dimensions of offscreen content, you can use document.body.scrollHeight and width for IE document.height and document.width should return a similar value for NS4.

Eddie Traversa

MikeFoster

8:26 am on Jan 6, 2002 (gmt 0)

10+ Year Member



Woah! I get to do the honors...

Hi Eddie!

Welcome to WebmasterWorld.com !

Brett_Tabke

9:31 am on Jan 6, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Welcome to the forums Eddie - used your tips and tricks often (thanks).
I'm sure you can find a snippet RC of Eddies somewhere (ck the tutorials section):

[dhtmlnirvana.com...]

rcjordan

4:27 pm on Jan 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>find a snippet

Heh! Where you been, BT?

[webmasterworld.com...]

[webmasterworld.com...]

Brett_Tabke

4:50 pm on Jan 6, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Hehe, I just wish Eddies site would work with Opera. Maybe we could lock him and Mike in a room together.

rcjordan

5:27 pm on Jan 6, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>lock him and Mike in

I'm not sure the web is ready for that.

>capturing the dimensions of offscreen content, you can use document.body.scrollHeight... document.height

I want to determine the total length of the onscreen ( innerHeight or document.body.clientHeight) plus the offscreen content yet to be scrolled, i.e, what's below the fold. I tried adding document.height or document.body.scrollHeight but that isn't working.

Hmmmm.... maybe the problem is because I'm using a remote js file and don't have the body id'd.

Eddie Traversa

1:00 am on Jan 7, 2002 (gmt 0)



Hi thanks for the welcome,

Opera needs to get more DOM support in or dramitically increase its client based before I start supporting it.

RC is this the problem, lets say you have a layer thats 2000 pixels long but on screen lets say 600 pixels of that layer is viewable. Are you wanting to capture the layers true height eg the 2000 value?

rcjordan

1:51 am on Jan 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>Are you wanting to capture the layers true height eg the 2000 value?

Yes. I was playing around with the alchemy script for dynamic image resizing [dhtmlnirvana.com] and thought it would be a great utility to have a spacer image that I could resize vertically on-the-fly, the length being based on the total content of the page. You could make unrelated side-by-side tables end at the same point, for example.

joshie76

4:22 pm on Jan 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Funny the way it works with IE and the document.body.clientHeight isn't it? The only way I've found around this is to place an absolutely positioned tag around the entire content (inside the body) and then collect the client height of that element. for example:


<body onload="alert(document.body.clientHeight);alert(document.getElementById('content').clientHeight)">
<div style="position:absolute" id="content">
content<br>
content<br>
content<br>
content<br>
content<br>
</div>
</body>

If you pad out the content so that it's longer than the fold you should see the desired results in the alert. Needless to say that this is IE (5+???) only.

When you think about it - this approach to grabbing the size of rendered elements can be incredibly useful! I've used it a lot for a recent high end IE5+ only application.... sweeet.

Josh

rcjordan

5:30 pm on Jan 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've worked out a solution, I add the heights of the divs. To get the cross-browser height of a div:

if (is.ns6 ¦¦ is.ns6x) {
var divHeight = document.getElementById("yourDivID").offsetHeight;
}
else if (is.dom) {
var divHeight = document.all["yourDivID"].offsetHeight;
}
else if (is.ns4) {
var divHeight = (document.layers["yourDivID"].document.height);
}

> incredibly useful!

Yep, I can mathematically position all divs on the page (NS4, NS6, IE). By determining the height and width of any div and have them as variables, I can then place other divs in what appears to be relative positioning. It's absolute positioning, so many of the NS4 problems go away (though there are still some to deal with).