An error occurred while loading CSS link dynamically in IE.

Source: Internet
Author: User

The dynamic loading of CSS is used today, but the following dynamic calling cannot be correctly loaded in IE. Of course, it is normal in Firefox and chrome.

$(function(){      var linkTmp = $('<link rel="stylesheet" type="text/css" />');      linkTmp.attr({          'href':'source/uploadify/resource/uploadify.css'      });      $('head').eq(0).append(linkTmp);})

At that time, I checked the HTML and found that this statement was successfully inserted in the head.
<LINK rel = "stylesheet" type = "text/CSS" href = "Source/uploadify/resource/uploadify.css"/>
But why does ie not dynamically load it?
Here is a classic explanation:
Once IE has processed all the styles loaded with the page, the only reliable way to add another stylesheet is with document. createstylesheet (URL)
Modify the Code as follows to load it successfully!

url ='style.css';if(document.createStyleSheet){    document.createStyleSheet(url);}else{      var linkTmp = $('<link rel="stylesheet" type="text/css" />');      linkTmp.attr({          'href':'source/uploadify/resource/uploadify.css'      });      $('head').eq(0).append(linkTmp);}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.