I have a page that loads some color values from a database and then a javascript needs to replace the stylesheet classes. For example the stylesheet has:
Expand|Select|Wrap|Line Numbers
- .txt_content {color: #ffffff;}
Then I call my script with changecss('.txt_content','color','#000000')
This works in FF, but not in IE. How do I solve this?
And another problem: how do I get it to change the hover pseudo-property of a link?
Here's the function:
Expand|Select|Wrap|Line Numbers
- function changecss(theClass,element,value) {
- var cssRules;
- if (document.all) {
- cssRules = 'rules';
- } else if (document.getElementById) {
- cssRules = 'cssRules';
- }
- for (var S = 0; S < document.styleSheets.length; S++){
- for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
- if (document.styleSheets[S][cssRules][R].selectorText == theClass) {
- document.styleSheets[S][cssRules][R].style[element] = value;
- }
- }
- }
- }
Tjeerd