Ticket #12145 (closed bug: patchwelcome)
adding a new css file using a relative url does not work in IE8 on Windows XP
|Reported by:||maspetsberger||Owned by:|
I added a new, relative css link using jQuery in the following way:
var style = jQuery("<link rel='stylesheet' type='text/css' href='style.css' />"); jQuery("head").append(style);
As far as I can tell, this works as expected on most browsers. However, in IE8 and Windows XP, it doesn't.
It works fine in IE8 browser mode of an IE9 on Windows 7, I can't tell whether a real IE8 on Windows 7 has the problem.
If I use an absolute url, like http://jQuery.com/style.css, it works for that specific file, i.e. style.css, yet it does not work for those files that are included through @import within it.
When I use the native way to add the styles, everything is fine:
var style = document.createElement("link"); style.setAttribute("type", "text/css"); style.setAttribute("rel", "stylesheet"); style.setAttribute("href", "style.css"); jQuery("head").appendChild(style);
This snippet, which uses the native way of adding, should work fine: http://jsfiddle.net/CNEsE/