Closed Bug 238592 Opened 20 years ago Closed 20 years ago

offsetWidth of span elements incorrectly returns zero only when certain elements are embedded in them.

Categories

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

defect
Not set
major

Tracking

()

RESOLVED INVALID

People

(Reporter: 77, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.6) Gecko/20040113
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.6) Gecko/20040113

When a non-positioned span element is embedded with certain HTML elements, the
offsetWidth property fails. The <IMG> element does not affect the property but
others like <TABLE>, <P>, and <CENTER> cause havok.

Reproducible: Always
Steps to Reproduce:
1.Embed any non-positioned span element with a <TABLE> or <P> element.
2.Call it's offsetWidth property with JavaScript 

Actual Results:  
Scripting returns zero.

Expected Results:  
Scripting should return something a hell of a lot more useful than zero.

This problem is huge! Some SUPER kool DHTML scrollbars are under development,
and  using the offsetWidth property of a non-positioned span element is the only
way to get the scrollbars to scroll horizontally. A pain the **** workaround is
to hardwire a variable for each page that holds the pixel width of the widest
element on the page. Every JavaScripter should see the brand new example of my
scrollbars and my workaround at <http://www.valleyfitness.com>. Please obtain
permission from 77@bradleyvisual.com to use my scripting.
I see this on LInux 2004042807
->DOM: Mozilla Extensions
Assignee: general → general
Component: Browser-General → DOM: Mozilla Extensions
QA Contact: general → ian
> The <IMG> element does not affect the property but
> others like <TABLE>, <P>, and <CENTER> cause havok.

That's because those are all blocks.  Put a border on the <span> to see what the
resulting boxes look like.  0 is in fact the correct offsetWidth....

See also bug 65548.
Status: UNCONFIRMED → RESOLVED
Closed: 20 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.