Availability
DOM Level 2 CSS
Synopsis
CSSStyleDeclaration getComputedStyle(Element elt,String pseudoElt);
Arguments
elt
The document element whose style information is desired. pseudoElt
The CSS pseudoelement, or null if there is none.
Returns
A read-only CSSStyleDeclaration object (which typically also
implements the CSS2Properties interface) that specifies the style
information used to render the specified element in this view. Any
length values queried from this object are always absolute or pixel
values, not relative or percentage values.
Description
An element
in a document may obtain style information from an inline
style attribute and from any number of style
sheets in the style-sheet "cascade." Before the element
can actually be displayed in a view, its style must be
"computed" by extracting style information from the
appropriate parts of the cascade.
This method allows access to those computed styles. By contrast, the
style property of an element gives you access only
to the inline styles of an element and tells you nothing about
style-sheet attributes that apply to the element. Note that this
method also provides a way to determine the actual pixel coordinates
at which an element is rendered in this view.
getComputedStyle( ) is actually defined by the
ViewCSS interface. In any DOM implementation that supports the View
and CSS modules, any object that implements AbstractView always
implements ViewCSS also. So, for simplicity, this method has been
listed with AbstractView.
In Internet Explorer, similar functionality is available through the
nonstandard currentStyle property of each
HTMLElement object.
See Also
CSS2Properties, CSSStyleDeclaration, HTMLElement.style
•
Table of Contents
•
Index
•
Reviews
•
Examples
•
Reader Reviews
•
Errata
JavaScript: The Definitive Guide, 4th Edition
By
David Flanagan
Publisher
: O'Reilly
Pub Date
: November 2001
ISBN
: 0-596-00048-0
Pages
: 936
Slots
: 1
This fourth edition of the definitive reference to
JavaScript, a scripting language that can be embedded
directly in web pages, covers the latest version of the
language, JavaScript 1.5, as supported by Netscape 6 and
Internet Explorer 6. The book also provides complete
coverage of the W3C DOM standard (Level 1 and Level 2),
while retaining material on the legacy Level 0 DOM for
backward compatibility.