IHTMLStyleSheet::addRule method
Creates a new rule for a style sheet.
Syntax
Integer* addRule( [in] BSTR sSelector, [in] BSTR sStyle, [in, optional] Integer iIndex = -1 );
Parameters
- sSelector [in]
-
BSTR that specifies the selector for the new rule. Single contextual selectors are valid. For example, "div p strong" is a valid contextual selector.
- sStyle [in]
-
BSTR that specifies the style assignments for this style rule. This style takes the same form as an inline style specification. For example, "color:blue" is a valid style parameter.
- iIndex [in, optional]
-
long that specifies the zero-based position in the rules collection where the new style rule should be placed.
Return value
Reserved. long that always specifies "-1".
Remarks
You can add up to 4,095 style rules with the IHTMLStyleSheet::addRule method. After that, the method returns E_INVALIDARG.
You can apply rules to a disabled styleSheet, but they do not apply to the document until you enable the styleSheet.
Examples
This example uses the IHTMLStyleSheet::addRule method to add a rule that sets all strong text appearing in a div to the color blue.
<style> </style> ... <div> Internet Explorer makes <strong>HTML</strong> dynamic. </div> <script> var new_rule; new_rule = document.styleSheets[0].addRule("div strong", "color:blue", 0); </script>
Requirements
|
Minimum supported client |
Windows XP |
|---|---|
|
Minimum supported server |
Windows 2000 Server |
|
Header |
|
|
IDL |
|
|
DLL |
|
See also