$("head").append('<link href="xxx.css" rel="stylesheet" type="text/css"/>');
I found this snippet is not working in IE 8?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
According to this bug report on the jquery site, there may well be a problem in IE8 with appending css files to the dom that contain relative links.
The poster of the bug suggests that adding it as follows may work:
Or that using an absolute url may also work:
Although he goes on to say that any files included through @import within the appended css file will also not load as expected.
I would suggest giving these test cases a whirl to see what loads for you and what doesn’t (if it works you should get a grey background in the HTML window):
Method Used in OP’s question: http://jsfiddle.net/vs5NC/20/
First possible solution from my answer: http://jsfiddle.net/vs5NC/17/
Second possible solution from my answer: http://jsfiddle.net/vs5NC/19/
If none of these work, it’s possible that Chris Fulstow’s answer to a similar question may be a viable solution.