Document.createStyleSheet() (Method)

A style sheet factory method.


JScript - 3.0
Internet Explorer - 4.0
Property/method value type:styleSheet object
JavaScript syntax:IEmyDocument.createStyleSheet()
IEmyDocument.createStyleSheet(aURL, anIndex)
Argument list:aURLThe URL to load the style sheet from
anIndexA location within the stylesheet list to insert this stylesheet

This is a means of adding a style sheet to a document from the JavaScript context.

When you create the style sheet, you have the choice of simply creating an empty styleSheet object or calling one in from a URL document source location.

You can also specify where in the hierarchy of currently loaded style sheets this new one should be placed by specifying its index location within the styleSheets collection.

If you can locate this styleSheet object once it has been installed, you can carry out further modifications on it by means of the addRule() method. This may be somewhat problematic on some browser versions and platforms since you don't get an object reference handle back from this method. You might be able to code around that, however, since you can specify a target index position in the styleSheets collection. That may mean you can get a reference to it indirectly once it has been added.


See also:Document object, StyleSheet object, StyleSheet.addRule()