1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
10 div.div3 {color: yellow }
14 div.div5 {color: purple }
19 var c
= document
.getElementById('console')
20 c
.appendChild(document
.createTextNode(str
+ '\n'));
24 var s1
= document
.getElementById('style1').sheet
;
26 // First append a style rule
27 s1
.insertRule('div.div2 {color: blue}', s1
.cssRules
.length
)
29 // Next, remove the first style rule
32 var s1
= document
.getElementById('style2').sheet
;
34 // Append a rule using the IE method
35 s1
.addRule('div.div4', 'color: green');
37 // Remove a rule using the IE method;
40 var s3
= document
.getElementById('style3').sheet
;
46 <body onload=
"runTests();">
49 This tests that insertRule, deleteRule, and the IE extensions addRule and removeRule update the style when rules are added and removed. It also tests that disabling a stylesheet updates the style.
50 <div class=
"div1">This is div1. This text should not be red because that rule has been removed.
</div>
51 <div class=
"div2">This is div2. This text should be blue because a matching rule with that property has been added.
</div>
52 <div class=
"div3">This is div3. This text should not be yellow because that rule has been removed.
</div>
53 <div class=
"div4">This is div4. This text should be green because a matching rule with that property has been added.
</div>
54 <div class=
"div5">This is div3. This text should not be purple because the stylesheet with that rule has been disabled.
</div>