PDA

View Full Version : javascript and XHTML


jewishj
11-01-2002, 08:11 AM
Hi,

What is the JavaScript of document.body.clientHeight when using IE 6 with the following doctype/html tags:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

document.body.clientWidth works fine as does:
screen.width, screen.height, window.innerWidth and window.innerHeight (in NS).

The problem is that document.body.clientHeight always returns 0.

Thanks in advance

Alex Vincent
11-02-2002, 11:33 PM
I think this question belongs in the main JavaScript forum. The mime-type will matter far more than the actual doctype tag, I think.

Moving thread.

jkd
11-02-2002, 11:39 PM
Try

document.documentElement.clientWidth

jewishj
11-03-2002, 02:46 AM
Originally posted by jkd
Try

document.documentElement.clientWidth

That would be document.body.clientWidth... body is the element...

and clientWidth works fine.. only clientHeight gives me problems..

Thanks

jkd
11-03-2002, 02:55 AM
document.documentElement refers to the root element in a page, and in the case of XHTML, <html>
not <body>.

Try document.documentElement.clientHeight if that's what you want.

jewishj
11-03-2002, 09:13 AM
OK... Thanks, you'll have to forgive my ignorance but that code that you gave me looked more like a syntax example, when I tried typing it exactly it worked though :D.

One question... when I use document.documentElement.clientHeight. it returns the size of one screen, but if there is enough content on the page to make a vertical scrollbar, it doesn't adapt. The same is true for window.innerHeight... do you know how I can retrieve the correct height of the content of the document.

or...

a different method of making the height of a <div> the height of the page content minus 95px?

Thanks in advance
:)