views:

48

answers:

0

Hi, i try to change the complete CSS code (like a stylebrowser).

First solution

new_css = ' body {color:#00ff00; } #div { border: 1px solid red; }';

$("head > style:eq(1)").html(new_css);

It works fine in the FF, Chrome & Safari ... but not in the the IE.

My second solution

var myStyle = document.styleSheets[1];

if( myStyle.cssRules )
{
    myStyle.insertRule('#dd { display:block; }', 0);            
} 
else
{
    if ( myStyle.rules )
    {
        myStyle.addRule('#dd'', 'display:block;');                  
    }
}

How can i change the complete CSS with the second solution. I found only the single "methods" removeRule, deleteRule, addRule, insertRule.

Thanks in advance! Peter

PS: Or is it maybe possible to use the first solution?