0

Once again, I turn to the expertise of the crowd :-)

I have appended a new stylesheet like so:

var css = "#newElement { color: #ff0000 }";
style = document.createElement('style');
    if (style.styleSheet) {
        style.styleSheet.cssText = css;
} else { 
        style.appendChild(document.createTextNode(css));
}
parent.document.getElementsByTagName('head')[0].appendChild(style);

I then create a new div like so:

var newElement = document.createElement("div");
newElement.id = "newElement";

The new style works fine on Firefox (turns to red) but not on Webkit (Chrome/Safari)... I dont have the means to test on IE...

Does anyone know if there is an issue with webkit that would cause this? or any tips on how I can get this to be compatible?

I need to change things like links and hover attributes so using the direct method of changing styles of a DOM object will not work and I do not have the option of using jQuery

Jesse Williams
  • 436
  • 4
  • 17

0 Answers0