Closed Thread Icon

Topic awaiting preservation: XHTML - document.body.clientHeight is always 0? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8341" title="Pages that link to Topic awaiting preservation: XHTML - document.body.clientHeight is always 0? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: XHTML - document.body.clientHeight is always 0? <span class="small">(Page 1 of 1)</span>\

 
Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 10-11-2002 05:01

I'm really starting to get annoyed with using the standards properly... Aren't they meant to make my life easier?

For some reason IE will always return 0 for document.body.clientHeight if I'm using a valid XHTML DTD!

document.body.clientWidth works fine, but document.body.clientHeight is always 0. I've tried everything I can think of, putting the script after the </body> tag, even after the </html> tag. I've tried setting it in a function onload, even with timeouts to make sure the whole page has been rendered and still I get no love. Maybe this is a bug but I couldn't find any mention of it on google. What's really cookin my noodle is that document.body.clientWidth works while document.body.clientHeight doesnt.

If I remove the DTD then it works fine.

Anyone else encountered this before?

For now I'm just going to use the age old table trick to center my content. At least it still works.

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 10-11-2002 05:24

Ok, now I'm really annoyed.

I think my version of IE is fried or something. I couldn't set a 100% height for a table (even using CSS) so I decided to drop back to a HTML 4 DTD and guess what. Still no love in document.body.clientHeight!

Then again, maybe this is just my version of IE.

Here's a test page with a HTML 4.01 Transitionl DTD
Here's a test page without any DTD

Maybe there's just something I'm forgetting... didn't cross a t or dot an i... Hell I sure hope so, cause I'm real close to wiping my hands of being standards compliant, ever.

[This message has been edited by Dracusis (edited 10-11-2002).]

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 10-11-2002 05:39

That's an easy one! Use document.documentElement.clientHeight instead!

*chuckles* =)

[edit: I'm kidding btw; I helped Dracusis with this one over ICQ, and did *not* find the answer as fast as I'm pretending to. =) ]

[This message has been edited by Slime (edited 10-11-2002).]

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 10-11-2002 05:42

"Thanks an easy one!" he says...

Yeah, easy for a walking DOM encylopedia. =)

Thanks again slime. Your a life saver.

[Edit: Yeah, it took him 10 seconds instead of 3.]

[This message has been edited by Dracusis (edited 10-11-2002).]

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 10-11-2002 06:00

Just been doing a little more playing with this and I've found that getting the width/height of the inner browser window while using a DTD is now different for the main three, Opera, Mozilla and IE.

For IE use:
document.documentElement.clientHeight or document.documentElement.clientWidth

For Opera use the old IE method:
document.body.clientWidth or document.body.clientHeight

For Mozilla use the old NN4 method:
window.innerWidth or window.innerHeight

Yay, yet another fork in my cross browser scripts.

Edit: document.documentElement.clientXXXXXX is an existing property in Mozilla but it will always return 0. Opera 6 doen't even have the document.documentElement object.

[This message has been edited by Dracusis (edited 10-11-2002).]

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

posted posted 10-14-2002 02:39

This really sucks. How are we supposed to move towards standards when the "standards" compliant browsers are still not standard? Agghhh!!! It's so frustrating.

BTW, thanks for posting this stuff because it really makes life easier when we work together on some of this stuff.

. . : slicePuzzle

[This message has been edited by Bugimus (edited 10-14-2002).]

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 10-14-2002 04:57

Hmm. I'm not sure browser interaction is covered in any specifications. ECMA covers the core Javascript language, and the W3C covers the DOM and some special things used to interact with HTML document specifically, but I don't think there's any standard for things that are specific to the environment outside of the web page, like the Screen object or window.open, and all that related stuff.

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 10-14-2002 09:37

Yeah well there should be!

Maybe someone should start up a test sight for XDHTML. Just exploring the differences between the browseres when their in standards compliant mode. Oh, everyone knows about always setting specific value types right, like blah.width = 5 won't work in mozilla but blah.width = "5px" will. THat one stumped me for several hours too.

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 10-14-2002 15:34

Anyone fancy drawing these thigns together in the FAQ?

PS has been doing something along these lines:
http://faq.ozoneasylum.com/532/

Dracusis: The idea of a test site sounds interesting fancy sketching out your ideas a little further?

___________________
Emps

FAQs: Emperor

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 10-14-2002 15:56

Me and my big mouth. =)

Give me 12 days to wreck myself on assignments then I'll come back and lay down some ideas. Unless someone else is keen to run with something right away.

« BackwardsOnwards »

Show Forum Drop Down Menu