I have the following javascript:
css = document.createElement('style');
css.setAttribute('type', 'text/css');
css_data = document.createTextNode('');
css.appendChild(css_data);
document.getElementsByTagName("head")[0].appendChild(css);
for some reason, in IE only, it chokes on "css.appendChild(css_data);" Giving the error: "Unexpected call to method or property access"
What's going on?
Try instead:
var css = document.createElement('style');
css.setAttribute('type', 'text/css');
var cssText = '';
if(css.styleSheet) { // IE does it this way
css.styleSheet.cssText = cssText
} else { // everyone else does it this way
css.appendChild(document.createTextNode(cssText));
}
document.getElementsByTagName("head")[0].appendChild(css);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With