4 out of 12 rated this helpful - Rate this topic

IHTMLDocument2::createStyleSheet method

Creates a style sheet for the document.

Syntax


IHTMLStyleSheet** createStyleSheet(
  [in, optional]  String sURL,
  [in, optional]  Integer iIndex
);

Parameters

sURL [in, optional]

A String that specifies how to add the style sheet to the document. If a file name is specified for the URL, the style information is added as a link object. If the URL contains style information, it is added to the style object.

iIndex [in, optional]

A Integer that specifies the index that indicates where the new style sheet is inserted in the styleSheets collection. The default is to insert the new style sheet at the end of the collection.

Return value

C++

a styleSheet object.

JavaScript

a styleSheet object.

Remarks

You can create up to 31 styleSheet objects with the createStyleSheet method. After that, the method returns an "Invalid Argument" exception. To create additional objects, use createElement and append them to the HEAD of the document as follows:


var styleSheet = document.createElement('STYLE');
document.documentElement.firstChild.appendChild(styleSheet);

Examples

This example uses the createStyleSheet method to create a link to a style sheet.


document.createStyleSheet('styles.css');

See also

IHTMLDocument2
document

 

 

Send comments about this topic to Microsoft

Build date: 11/29/2012

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.