Availability: |
| ||||||
JavaScript syntax: | - | myStyleSheet = myDocument.styleSheets[anIndex] | |||||
IE | myStyleSheet = myDocument.createStyleSheet() | ||||||
Argument list: | anIndex | A valid reference to an item in the collection | |||||
Object properties: | cssText, disabled, href, id, media, ownerNode, owningElement, owningNode, parentStyleSheet, readOnly, title, type | ||||||
Object methods: | addImport(), addRule(), removeRule() | ||||||
Collections: | cssRules[], imports[], rules[] |
A style sheet contains many individual style objects which are managed as a collection. These style sheet objects are created by means of the <STYLE> HTML tag or are imported with the <LINK> tag. They can also be created by means of the @import statement inside a style definition.
The Document.styleSheets[] collection contains a reference for every styleSheet object in the document.
Beware that a STYLE object and a style object are different things. A STYLE object is instantiated by the <STYLE> HTML tag and contains properties that reflect its attributes.
This is quite different to a style object which is a member of a styleSheet and describes the rules for a particular style.
DOM level 2 adds the following properties:
title
media
ownerRule
It also adds the following methods:
insertRule()
deleteRule()
Note that MSIE 5 incorrectly names this object class as styleSheet instead of StyleSheet (note the capitalization).
Property | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
cssText | ![]() | 5.0 ![]() | ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
disabled | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | - |
href | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ReadOnly. |
id | ![]() | 5.0 ![]() | ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly. |
media | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ![]() |
ownerNode | 1.5 ![]() | ![]() | 6.0 ![]() | ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ReadOnly. |
owningElement | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly. |
owningNode | ![]() | 5.0 ![]() | ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
parentStyleSheet | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ReadOnly. |
readOnly | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ReadOnly. |
title | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ![]() |
type | 1.5 ![]() | 3.0 ![]() | 6.0 ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ReadOnly. |
Method | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
addImport() | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
addRule() | ![]() | 3.0 ![]() | ![]() | 4.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
removeRule() | ![]() | 5.0 ![]() | ![]() | 5.0 ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | - |
Prev | Home | Next |
<STYLE TYPE="..."> | Up | StyleSheet.addImport() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |