Section 25.300. Window.getComputedStyle( ): retrieve the CSS styles used to render an element


25.300. Window.getComputedStyle( ): retrieve the CSS styles used to render an element

DOM Level 2 CSS:

25.300.1. Synopsis

 CSS2Properties getComputedStyle(Element elt,                                 String pseudoElt); 

25.300.1.1. Arguments

elt

The document element whose style information is desired.


pseudoElt

The CSS pseudoelement string, such as ":before" or ":first-line", or null if there is none.

25.300.1.2. Returns

A read-only CSS2Properties object that represents the style attributes and values used to render the specified element in this window. Any length values queried from this object are always expressed as pixel or absolute values, not relative or percentage values.

25.300.2. Description

An element in a document may obtain style information from an inline style attribute and from any number of style sheets in the stylesheet "cascade." Before the element can actually be displayed in a view, its style information must be extracted from the cascade, and styles specified with relative units (such as percentages or "ems") must be "computed" to convert to absolute units.

This method returns a read-only CSS2Properties object that represents those cascaded and computed styles. The DOM specification requires that any styles representing lengths use absolute units such as inches or millimeters. In practice, pixel values are commonly returned instead, although there is no guarantee that an implementation will always do this.

Contrast getComputedStyle( ) with the style property of an HTMLElement, which gives you access only to the inline styles of an element, in whatever units they were specified, and tells you nothing about stylesheet styles that apply to the element.

In Internet Explorer, similar functionality is available through the nonstandard currentStyle property of each HTMLElement object.

25.300.3. See Also

CSS2Properties, HTMLElement




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net