Skip to main content

Bug Tracker

Side navigation

#12145 closed bug (patchwelcome)

Opened July 25, 2012 03:15PM UTC

Closed August 21, 2012 02:37AM UTC

adding a new css file using a relative url does not work in IE8 on Windows XP

Reported by: maspetsberger Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

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' />");

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 '''', 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");

This bug is similar to, which unfortunatly was closed.

The snippet reported there is still valid though:

This snippet, which uses the native way of adding, should work fine:

Attachments (0)
Change History (1)

Changed August 21, 2012 02:37AM UTC by dmethvin comment:1

resolution: → patchwelcome
status: newclosed

The problem appears to be that IE does not like trying to process the relative URL without knowing the base address of the page where it isn't yet placed. This hybrid works fine in IE8:

I don't think this can be fixed inside jQuery, it's an HTML serialization issue, but I'll mark it patchwelcome.