I have a problem with adding a dynamic style element with @import statements for IE. Try this:
var string = '@import url(test.css)';
var style = document.createElement('style');
if (style.styleSheet) { // IE
style.styleSheet.cssText = string;
} else {
var cssText = document.createTextNode(string);
style.appendChild(cssText);
}
document.getElementsByTagName('head')[0].appendChild(style);
This works for FF/Chrome but not IE. It seems to recognize style.styleSheets.imports
, but it will not apply the imported stylesheet. Is this a bug or limitation?