Closed
Bug 69035
Opened 24 years ago
Closed 23 years ago
offsetHeight is reported wrongly
Categories
(Core :: DOM: Core & HTML, defect, P3)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
WORKSFORME
mozilla1.0.1
People
(Reporter: christopher_brien, Assigned: jst)
References
Details
(Keywords: dom0)
Attachments
(1 file, 1 obsolete file)
1.33 KB,
text/html
|
Details |
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•24 years ago
|
||
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•24 years ago
|
||
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.
Assignee | ||
Comment 3•24 years ago
|
||
Testcase?
Comment 4•24 years ago
|
||
Comment 5•24 years ago
|
||
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).
Assignee | ||
Comment 6•24 years ago
|
||
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?
Status: UNCONFIRMED → ASSIGNED
Component: DOM Level 1 → DOM Level 0
Ever confirmed: true
OS: Windows NT → All
Priority: -- → P3
Hardware: PC → All
Target Milestone: --- → mozilla1.0
Reporter | ||
Comment 7•24 years ago
|
||
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•24 years ago
|
||
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•23 years ago
|
||
Chris Brien, could you please re-test this now that offset* properties were modifed to match IE's behavior? Thanks in advance!
Comment 10•23 years ago
|
||
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 moved)
Target Milestone: mozilla1.0 → mozilla1.0.1
Comment 11•23 years ago
|
||
Notice how this test case shows that IE6 and Mozilla are both giving the same results. (Except that IE does not support innerWidth/Height)
Attachment #25462 -
Attachment is obsolete: true
Comment 12•23 years ago
|
||
Marking worksforme, since this is working identically in IE6 and Mozilla....
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → WORKSFORME
Comment 13•23 years ago
|
||
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•20 years ago
|
||
*** Bug 258531 has been marked as a duplicate of this bug. ***
You need to log in
before you can comment on or make changes to this bug.
Description
•