Forum Moderators: open

Message Too Old, No Replies

Using JS to Edit CSS Classes in IE

IE is the bane of my existence

         

eonta

5:51 pm on Jul 19, 2004 (gmt 0)



Mozilla has this handy javascript handle for CSS classes:

document.styleSheets[x].cssRules[x].style

However, when I edit style attributes in this manner, IE6 pops up an error that the return value is either null or not an object. I need to edit the class attributes, not the attributes for a specific element or type of element, so the common document.getElementBy... won't work for me. Any thoughts would be appreciated.

Bernard Marx

6:33 pm on Jul 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IE (as it often does) has a non-standard name for its rules collection: 'rules'.

[replace ¦¦ with unbroken pipes]

var rules = document.styleSheets[x].cssRules¦¦document.styleSheets[x].rules
//-->