Why does the IE browser load CSS files but does not work?

Source: Internet
Author: User
If one day, you suddenly find that the script you write does not work, and all of this happens only on IE browser, what do you do? You think you writeProgramWhat if there is a problem? Or do you think there is a problem with the IE processing program? In fact, you don't need to think about this problem. It must be because there is a problem with the program we wrote. Because we are programmers, the solution is to make an application compatible with all mainstream browsers. If the application has problems, our solutions are not mature. This problem has been found for a long time, but has been busy developing system functions without solving browser compatibility solutions. Recently, I got a chance to solve this problem. I will first describe the manifestation of this bug. The page is displayed normally in Firefox and other browsers, but some CSS styles in IE are not applied. Note that not all CSS styles do not work, but some CSS does not work in IE, here we can eliminate the problem of not referencing JS files or referencing JS paths abnormally. When the above problem occurs, our first response is usually caused by the nonstandard CSS syntax. These CSS syntaxes can be identified in Firefox, but not in IE, we know that different browsers have some differences in parsing CSS style sheets. Yes, I suspect that my CSS syntax is not standard, but after careful review, I found that it is not a syntax problem. First, the CSS syntax adopts the standard general syntax, which is the same in each browser. Second, the corresponding class is not sniffed in IE. It can be concluded that the CSS files are not correctly introduced. However, our CSS files are introduced in the same way, and are all referenced under the same commonthemes file. There are two advantages to doing so: one is to facilitate the management of CSS files; the second is to reduce errors caused by incorrect reference paths. As usual, this should not be a problem, but it is also the problem of IE, which is not a common sense. In IE browser, when <SCRIPT type = "JavaScript"/> is used to reference files, ie can only identify 31 files. If there are more than 31 referenced files, ie will automatically filter out. Because we put all the CSS files in the system under the commonthemes directory, far more than 31. Therefore, files after 31st CSS files no longer work. In this case, We must split the CSS file into different <SCRIPT> labels to prevent a <SCRIPT> label from loading more than 31 CSS files. Our solution is to divide CSS referenced files into multiple files according to the system architecture and business requirements, so that the number of CSS paths under each file cannot exceed 31. Ie can reference up to 31 files. Generally, we do not need to introduce so many files in a script. IE may want to improve the system running efficiency and prevent memory leakage. Only by its own self-thinking, the file is filtered, it is really not. Don't forget that the programmer's goal is to solve the problem, not to create the problem.
Related Article

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.