Closed Bug 300101 Opened 19 years ago Closed 19 years ago

[quirks] offsetWidth and style.width yield different values

Categories

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

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: stefan, Unassigned)

References

Details

(Keywords: testcase)

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

The following html source reproduces the effect:

<html>
<body>
<div id="e" style="left:20px; top:20px; width:40px; height:80px; margin:0px;
padding:0px; border:2px solid black;">
</div>
<script type="text/javascript">
   var e = document.getElementById("e");
   window.alert(e.offsetWidth + " / " + e.style.width);
</script>
</body>
</html>

the same effect applies to "offsetHeight / style.height".
the difference seems to be the double border-width.

Reproducible: Always



Expected Results:  
the values should be equal.

IE6 and opera 8 behave as expected with equal values.

Firefox also behaves not according to the documentation

http://www.mozilla.org/docs/dom/domref/dom_el_ref22.html#1028090
Related to Core bug 65548?
Attached file Testcase
IE & Opera returs "40 / 40 px", Mozilla "44 / 40px" (in quirks mode)

In standard compliance mode, they all give the same result, "44 / 40px"
Assignee: nobody → general
Component: General → DOM: Level 0
Keywords: testcase
Product: Firefox → Core
QA Contact: general → ian
Version: unspecified → Trunk
(In reply to comment #2)
> Created an attachment (id=188770) [edit]
> Testcase
> 
> IE & Opera returs "40 / 40 px", Mozilla "44 / 40px" (in quirks mode)
> 
> In standard compliance mode, they all give the same result, "44 / 40px"

1) how can I switch IE & Opera to standard compliance mode, to verify this?

2) what does standard compliance mode mean here, as 'offsetWidth' is a DHTML
extension originally implemented in IE and not part of W3C DOM ?
(In reply to comment #2)
ok, I understand that the difference results from IE's quirky CSS2 box model
implementation.

thanks ..
> 1) how can I switch IE & Opera to standard compliance mode, to verify this?

Add or remove a strict doctype declaration. You can query the
document.compatMode string to verify the type of rendering mode in MSIE 6.
 
> 2) what does standard compliance mode mean here, as 'offsetWidth' is a DHTML
> extension originally implemented in IE and not part of W3C DOM ?

In backward compatible mode in MSIE 6, the CSS width is equal to the DHTML
offsetWidth value as shown by this image
http://msdn.microsoft.com/library/en-us/dnie60/html/boxdim.gif



Maybe Mozilla should follow MSIE 6 when in backward compatible mode. This is up
to module owner.
EIMS 
Blocks: 196779
> Related to Core bug 65548?
Bug 65548 involves nested boxes: a containing box and a contained inner box.

I'm updating the summary to reflect on what consists this bug here. 

Component: DOM Mozilla extensions

CONFIRMING
.56 

guB


b uB
Status: UNCONFIRMED → NEW
Component: DOM: Level 0 → DOM: Mozilla Extensions
Ever confirmed: true
Summary: with javascript "offsetWidth" and "style.width" yield different values → [quirks] offsetWidth and style.width yield different values
This is invalid.

The offsetWidth/Height returns the border-box size (outer size) where
style.width/height returns the current value (not even the computed value).
Status: NEW → 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: