I dynamically load a css stylesheet (with a little help from jQuery) like this:
var head = document.getElementsByTagName('head')[0];
$(document.createElement('link'))
.attr({ type: 'text/css', href: '../../mz/mz.css', rel: 'stylesheet' })
.appendTo(head);
This works fine in Firefox and Google Chrome, but not in IE.
Any help? Thanks
This might also have something to do with it - Taken from Microsoft Support article:
It seems that
works also in IE as long as the url is a fully qualified URI including the protocol...
This also seems to work in IE:
Once IE has processed all the styles loaded with the page, the only reliable way to add another stylesheet is with
document.createStyleSheet(url)
See the MSDN article on createStyleSheet for a few more details.
Open ie8 without the debugger open. When you get to after the point of dynamic stylesheet... open the debugger and voila, they should be there.
You need to set the href attr last and only after the link elem is appended to the head: