Closed Bug 297284 Opened 20 years ago Closed 19 years ago

JS clientHeight not correctly detected

Categories

(Core :: DOM: Core & HTML, defect)

1.0 Branch
x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: jab_creations, Unassigned)

References

()

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b2) Gecko/20050525 Firefox/1.0+
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b2) Gecko/20050525 Firefox/1.0+

The url example shows that FF can detect the clientWidth but not height.

The first promt is clientwidth...
second is clientwidth -20
third is clientheight
fourth is clientheight -20

Reproducible: Always

Actual Results:  
clientHeight is detected as 0 on third prompt and -20 on fourth prompt.

Expected Results:  
This script works correctly in IE 6 (XP sp1) and Opera 8.  Various browsers with
differing toolbars will change the height obviously.

I am curious if there is another way to currently detect the height of the
client rendering area?  I use clientHeight on my site and have for some time.

From my perspective clientHeight is correctly detected and used, it just does
not seem to be correctly rendered as a numerical value perhaps?
Attached file testcase
The <body> has a height of 0px, so the clientHeight (which is equivalent to
.offsetHeight afaik) is also 0px.
When you put textual content in the body, you'll see the clientHeight property
grows higher.
If you want the document height in Mozilla, you can use window.innerHeight +
window.scrollMaxY.
Assignee: nobody → general
Component: General → DOM: Mozilla Extensions
Product: Firefox → Core
QA Contact: general → ian
Version: unspecified → 1.0 Branch
Would someone be kind enough to explain the difference between
window.innerHeight and document.body.clientHeight?  What is the intended purpose
of each?  Why should Opera, IE, and Gecko all recognize clientWidth but not
clientHeight?

I am sure there must be some standards as well.  Who sets the standards for
Javascript?
window.innerHeight is the height of the viewport, see:
http://www.mozilla.org/docs/dom/domref/dom_window_ref27.html
document.body.clientHeight is the height of the body element.
offsetHeight=height+border-bottom-width+border-top-width, clientHeight = height,
see:
http://www.mozilla.org/docs/dom/domref/dom_el_ref18.html
http://www.mozilla.org/docs/dom/domref/clientHeight.html

See also bug 260498, where a similar discussion took place (but there's some
more info there also).
*** Bug 304142 has been marked as a duplicate of this bug. ***
Martijn is correct here: the default width will be the viewport for the block
element of body, but it's default height is 0.

-->INVALID
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
Component: DOM: Mozilla Extensions → DOM
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: