Beginning on October 25th, 2016, Persona will no longer be an option for authentication on BMO. For more details see Persona Deprecated.
Last Comment Bug 69035 - offsetHeight is reported wrongly
: offsetHeight is reported wrongly
: dom0
Product: Core
Classification: Components
Component: DOM: Core & HTML (show other bugs)
: Trunk
: All All
: P3 normal (vote)
: mozilla1.0.1
Assigned To: Johnny Stenback (:jst,
: Prashant Desale
: Jet Villegas (:jet)
: 258531 (view as bug list)
Depends on:
  Show dependency treegraph
Reported: 2001-02-16 05:19 PST by Chris Brien
Modified: 2014-10-11 14:00 PDT (History)
6 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

testcase to show the offsetWidth, offsetHeight, innerWidth, and innerHeight (773 bytes, text/html)
2001-02-16 12:18 PST, Tim Powell
no flags Details
This test case uses the documentElement as well (1.33 KB, text/html)
2001-12-13 08:20 PST, Erik Arvidsson
no flags Details

Description Chris Brien 2001-02-16 05:19:11 PST
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)
BuildID:    2001021520

The property document.body.offsetHeight should return the height of the html 
rendering area. Instead, it returns the height of the content.
document.body.offsetWidth works properly.

Reproducible: Always

Steps to Reproduce:
Put a script into a page which includes something like this:

alert("The viewable area is " + document.body.offsetWidth + " pixels wide and " 
+ document.body.offsetHeight + " pixels high.");

Actual Results:  offsetWidth is reported correctly, whereas offsetHeight is the 
height of the actual content.

Expected Results:  Both offsetHeight and offsetWidth should report the size of 
the HTML rendering area.
Comment 1 Boris Zbarsky [:bz] (still a bit busy) 2001-02-16 11:30:40 PST
Actually, doesn't offsetHeight just return the height of the DOM object
representing the body?  If so, that's not the height of the rendering area at
all, it _is_ the height of the content.

Does IE do it differently (giving you the height of the viewport)?
Comment 2 Tim Powell 2001-02-16 11:56:16 PST
I would think that offsetHeight would show the height of the content (which may
be more or less than the viewport size). If you want the viewport size you could
use window.innerHeight in Netscape 4.x and Mozilla.
Comment 3 Johnny Stenback (:jst, 2001-02-16 12:02:42 PST
Comment 4 Tim Powell 2001-02-16 12:18:44 PST
Created attachment 25462 [details]
testcase to show the offsetWidth, offsetHeight, innerWidth, and innerHeight
Comment 5 Tim Powell 2001-02-16 12:23:58 PST
The values for document.body.offsetHeight is different than window.innerHeight
in the attached testcase. This is also true for document.body.offsetWidth
compared to window.innerWidth, so I'd say the original report is incorrect:
body.offsetWidth does not return the size of the viewport.

I'd say this is not a bug. If anything, I'd say IE's results are incorrect (and
IE doesn't support innerHeight and innerWidth).
Comment 6 Johnny Stenback (:jst, 2001-02-16 12:40:17 PST
It's hard to say that IE's .offsetXXX properties are incorrect since there's no
spec for those properties. What IE does is what's correct, unfortunately. The
semantics of these properties never cease to amaze me.

I don't know what to do here yet, but whatever is done it won't happen until
past mozilla0.9.1. Does existing sites break because of this?
Comment 7 Chris Brien 2001-02-19 01:23:32 PST
It's strange that the values for height and width seem to be different things. 
offsetWidth doesn't report the width of the content, but the width of the 
viewport, so I'd expect offsetHeigth to do the same.
This inconsistency makes it impossible to center things on screen, which is 
what I was trying to do when I noticed this bug.
Comment 8 Boris Zbarsky [:bz] (still a bit busy) 2001-02-19 12:07:50 PST
Well, if I recall correctly, what mozilla reports for the offsetHeight and
offsetWidth are just the height and width CSS2 properties of the corresponding
box (so in this case, the height and width of the <body> box).  And if you put a
border around <body>, you'll see that the width of <body> is the width of the
viewport unless specified otherwise, while the height is the height of the
content unless specified otherwise.

If you want to center things, you should probably "specify otherwise" for the
body tag... something like:

body { position: absolute; left: 0; right: 0; top: 0; bottom: 0; margin: 0;
padding: 0 }
Comment 9 Fabian Guisset 2001-08-30 11:46:34 PDT
Chris Brien, could you please re-test this now that offset* properties were
modifed to match IE's behavior? Thanks in advance!
Comment 10 Asa Dotzler [:asa] 2001-12-03 10:58:42 PST
Bugs targeted at mozilla1.0 without the mozilla1.0 keyword moved to mozilla1.0.1 
(you can query for this string to delete spam or retrieve the list of bugs I've 
Comment 11 Erik Arvidsson 2001-12-13 08:20:14 PST
Created attachment 61583 [details]
This test case uses the documentElement as well

Notice how this test case shows that IE6 and Mozilla are both giving the same
results. (Except that IE does not support innerWidth/Height)
Comment 12 Boris Zbarsky [:bz] (still a bit busy) 2001-12-13 08:26:23 PST
Marking worksforme, since this is working identically in IE6 and Mozilla....
Comment 13 Erik Arvidsson 2001-12-13 08:29:50 PST
I was also going to add a comment but it got lost in cyberspace.... here we go again

This bug is invalid.

The offset* for body should give the size of the body element. Notice that
Mozilla and IE6 in CSS1Compat mode behaves exactly the same. The reason why IE
(before IE6) gave the window inner size (for body.offset*) was that IE treated
the body element as the document canvas.
Comment 14 Robin Monks 2005-01-10 11:33:07 PST
*** Bug 258531 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.