Closed Bug 34529 Opened 25 years ago Closed 25 years ago

Styles declared in HTML <STYLE> element are not accessible to JavaScript

Categories

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

x86
Windows NT
defect

Tracking

()

VERIFIED INVALID

People

(Reporter: aw, Assigned: jst)

References

Details

From Bugzilla Helper: User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT) BuildID: 2000040415 Only styles specified via the inline STYLE attribute are accessible to JavaScript (via object.style.property). Styles specified via the <STYLE> element or referenced externally via <LINK> are not accessible to JavaScript. Reproducible: Always Steps to Reproduce: 1. Load this HTML document: <html> <head> <style type="text/css"> #foo2 { color:red; } </style> </head> <body> <!-- inline styles are accessible, external are not --> <div id="foo1" style="color:red" onclick="alert(this.style.color)"> Foo1 </div> <div id="foo2" onclick="alert(this.style.color)"> Foo2 </div> </body> </html> 2. Click on the Foo1 and Foo2 DIVs. Actual Results: Clicking on the Foo1 DIV displays an alert with "red". Clicking Foo2 displays an alert with nothing. Expected Results: Both DIVs should display an alert with "red". this.style.color is not returning a value for the DIV whose style was specified in the <STYLE> element instead of inline.
I don't think it is a valid bug. You can't get the value of property that has not been set. Reassigned to jst for confirmation. MacIE5.5 shows the same behavior.
Assignee: pierre → jst
Component: Style System → DOM Level 1
*** Bug 37518 has been marked as a duplicate of this bug. ***
Mozilla does erxactly the right thing here, from the current DOM Level 2 CSS spec: Inline style information attached to elements is exposed through the style attribute. This represents the contents of the STYLE attribute for HTML elements (or elements in other schemas or DTDs which use the STYLE attribute in the same way). To get the actual style that is applied to a spcific element the function getComputedStyle() should be used, this does not yet work in mozilla, but I'm working on implementing it. Marking this bug as INVALID.
Status: UNCONFIRMED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
D'oh, I meant INVALID, not FIXED!
Status: RESOLVED → UNCONFIRMED
Resolution: FIXED → ---
Trying to make this INVALID again, sorry about the spam!
Status: UNCONFIRMED → RESOLVED
Closed: 25 years ago25 years ago
Resolution: --- → INVALID
Adding 'verifyme' keyword
Keywords: verifyme
Mass update of qa contact
QA Contact: chrisd → janc
verified
Status: RESOLVED → VERIFIED
Keywords: verifyme
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.