Packagedom.style.css
Interfacepublic interface ViewCSS extends AbstractView
Implementors Window

Introduced in: DOM 2 Core 

This interface represents a CSS view. The getComputedStyle method provides a read only access to the computed values of an element.

The expectation is that an instance of the ViewCSS interface can be obtained by using binding-specific casting methods on an instance of the AbstractView interface.

Since a computed style is related to an Element node, if this element is removed from the document, the associated CSSStyleDeclaration and CSSValue related to this declaration are no longer valid.

See also

W3C - DOM Level 2 Style: ViewCSS


Public Properties
 PropertyDefined By
 InheritedDOM 2 Views document : DocumentView
[read-only] The source DocumentView of which this is an AbstractView.
AbstractView
Public Methods
 MethodDefined By
  
This method is used to get the computed style as it is defined in CSS2.
ViewCSS
Method Detail
DOM 2 Style getComputedStyle()method
public function getComputedStyle(elt:Element, pseudoElt:DOMString):CSSStyleDeclaration

Introduced in: DOM 2 Core 

This method is used to get the computed style as it is defined in CSS2.

Parameters

elt:Element — The element whose style is to be computed. This parameter cannot be null.
 
pseudoElt:DOMString — The pseudo-element or null if none.

Returns
CSSStyleDeclaration — The computed style. The CSSStyleDeclaration is read-only and contains only absolute values.

See also


Example
         var element = document.getElementById(“elemId”);
         var style = document.defaultView.getComputedStyle(element, pseudoElt);
         //practical example:
         <html>
         <head>
             <style>
                 #elem_container{
                     position: absolute;
                     left: 100Px;
                     top: 200px;
                     height:100px;
                 }
             </style>
         </head>
         <body>
             <div id="elem_container">dummy</div>
         
             <div id="output"></div>  
             <script>
                 function getTheStyle() {
                     var elem=document.getElementById("elem_container");
                     var theCSSprop=document.defaultView.getComputedStyle(elem,null).getPropertyValue("height");
                     document.getElementById("output").innerHTML=theCSSprop;
                 }
             getTheStyle();
             </script>
         </body>
         </html>