...

View Full Version : Resolved Are style elements counted in document.styleSheets array?



Hamza7
07-16-2011, 07:35 PM
I have one question about <style> elements, are they counted in document.styleSheets array? and can I add rules to them by using insertRule() and deleteRule() methods? :confused:

devnull69
07-16-2011, 09:14 PM
Generally speaking ... yes

But: As always IE is cooking for a different party ... the methods are called addRule and removeRule there.

Normal browsers


var myrules = document.styleSheets[0].cssRules; // all the rules
var myStyle = document.styleSheets[1];
myStyle.insertRule(...);


IE


var myrules = document.styleSheets[0].rules; // all the rules
var myStyle = document.styleSheets[1];
myStyle.addRule(...);

Hamza7
07-17-2011, 02:18 PM
Thanks, I knew that IE use addRule() and removeRule(), but I am working on a script that works on FireFox, so I don't have to target IE.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum