Name

createStyleSheet( ) — NN n/a IE 4 DOM n/a

Synopsis

createStyleSheet([”url“[, index]])

Creates and adds a new style sheet for the document. This is also the method you can use to dynamically load an external style sheet after the document has already loaded. To do so, specify the URL of the external .css file as the first parameter. If you’d rather script the addition of individual style sheet rules, you can do so in the Win32 version only. Specify an empty string for the first parameter and then use the addRule( ) method for the styleSheet object for each rule you wish to dynamically add to the style sheet.

Returned Value

styleSheet object reference (but null in IE 4/Macintosh, preventing further assignments of rules).

Parameters

url

A string of the URL of an external .css style sheet definition file.

index

Optional zero-based integer that indicates where among the styleSheets[] collection this new style sheet should be inserted. Default behavior is to append to the end of the collection, but this may affect cascading rules for your document. See Chapter 3.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.