Internet Explorer“CSS由于MIME类型不匹配而被忽略”对本地文件(无服务器)
我正在开发一个应用程序,最后创建一个HTML报告,它分别输出js和css文件,然后正常加载文件。但Internet Explorer 8-10 +拒绝加载CSS文件,因为由于mime类型不匹配而忽略CSS,但是当然,MIME不能修改,因为它们是本地文件和不由服务器提供。
I'm developing an application which creates a HTML report at the end, it outputs the js and css files separately then loads the files normally. But Internet Explorer 8-10+ refuses to load the CSS files due to "CSS was ignored due to mime type mismatch", but of course, the MIME can't be modified, as they are local files and not being served by a server.
简而言之:
- 本地文件(C:\,file ://,etc)
- CSS将由于MIME类型不匹配而无法加载
- 不是http://或localhost或任何变体
- Local files (C:\,file://,etc)
- CSS Won't load due to "MIME type mismatch"
- Works in every other browser without issue -_-
- Not "http://" or "localhost" or any variant
CSS的HTML载入:
HTML loading of CSS:
<head>
<title>Results</title>
<link href='resources/bootstrap.min.css' rel='stylesheet' type='text/css' />
<link href='resources/bootstrap-responsive.min.css' rel='stylesheet' type='text/css' />
<link href='resources/style.css' rel='stylesheet' type='text/css' />
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
</head>
注意:
根据 Microsoft ,修复是:确保样式表文件包含正确的HTTP响应头,其中包含一个内容类型为text\css。有关详细信息,请参阅MIME Explorer处理Internet Explorer中的更改。,但显然不可能,因为没有头
Note: According to Microsoft, the fix is: "Ensure style sheet file is delivered with the proper HTTP response header, which includes a content type of text\css. See MIME-Handling Changes in Internet Explorer for more information.", but obviously impossible, as no header's are being sent across the wire......
通过在几台不同的机器上测试发现了这个问题,如果你有一个CSS文件设置为打开一个特定的程序,它将阻止IE加载,并将给出上述错误消息-_-
Found out the issue by testing on a few different machines, it turns out if you have a CSS file set to open with a particular program, it will prevent IE from loading, and will give the above error message -_-
同时减轻潜在问题,通过在文件的结尾包含CDN版本的CSS(报告必须与无互联网工作)
Also mitigating the potential problem by including a CDN version of the CSS at the end of the file (the report has to work with and without internet)