|
-
Sep 6th, 2006, 01:00 PM
#1
Thread Starter
Member
DOM Properties
When i query an objects properties they are blank
for example:
var node = document.getElementById("id")
var sdisplay = node.style.display
sdisplay will be blank, however the object has been assigned a display setting (blank, and the object does abide by the setting).
I can assign to the property and from then onwards i can retrieve it etc its just when the page initially loads.
Any ideas?
-
Sep 6th, 2006, 02:13 PM
#2
Re: DOM Properties
The style property represents the inline styles of the element, not the active styles. If the display property was set via a CSS rule, it won't show up.
Due to lack of support in IE, there is no portable way of retrieving the active style of an element. The standard (DOM 2 Style Module, chapter CSS) method is using the getComputedStyle() method of the window (or any other ViewCSS) object. You pass it the node and the pseudo-element, and it will return the currently active fully computed style.
In IE, you can instead use the currentStyle property of the node object itself. This method doesn't allow retrieving the style of pseudo-elements, but then, IE doesn't support them anyway.
See also this article for more information:
http://www.oreillynet.com/pub/a/java...p5/index5.html
Be aware of at least one mistake, though: there is no need to call the getPropertyValue() method on the return value of getComputedStyle(). You can use array indexing syntax and use the JS-style property names that you're used to.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|