How do you access the DOM CSS interfaces?

How do you gain access to interfaces like ''CSSStyleDeclaration'?

I am currently experimenting with the DOM in Netscape 6.1  If I want to modify 
CSS properties for an element, how do I gain access to interfaces like 
''CSSStyleDeclaration'?  Is it the user agent's responsibility to get me to 
that point, or is the developer supposed to do something? 


For the purposes of this question, refer to this markup fragment:

<div id="div_one" style="width: 100px; height: 100px; background-color: 
#7F7FFF;"> Blah blah blah
</div>

Let's say I want to change the value of the 'background-color' property.  Using 
JavaScript I can access that element by, among other ways, using this syntax: 
document.getElementById( 'div_one' ). 

If I execute a script with this statement:

alert( document.getElementById( 'div_one' ).style );

Netscape displays this: [object CSSStyleDeclaration].  Then I can access the 
properties and methods of that interface. 

However, I'm not going to use that syntax because section 1.6.1 of the DOM HTML 
states: "HTML attributes are exposed as properties on the element object...This 
usage is deprecated ...We recommend the use of generic methods on the core 
Element interface for setting, getting and removing attributes."  Even if that 
usage wasn't deprecated, I would still want to use the generic methods from DOM 
Core because DOM HTML is not stable. 

I've experimented and as far as I can tell, the generic methods in DOM core 
will only get me the value of the 'style' attribute as a DOMString, or get me 
an Attr node, neither of which is connecting me with the DOM CSS interfaces.  
How do I get the DOMString to be a CSSStyleDeclaration?  Is the DOM 
Implementation supposed to do it automatically, or is there some manual way for 
me to do it? 

Received on Sunday, 4 November 2001 16:20:24 UTC