Internet Explorer“由于 MIME 类型不匹配,CSS 被忽略"在本地文件上(无服务器) [英] Internet Explorer "CSS was ignored due to mime type mismatch" on local files (no server)

查看:33
本文介绍了Internet Explorer“由于 MIME 类型不匹配,CSS 被忽略"在本地文件上(无服务器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,它在最后创建一个 HTML 报告,它分别输出 js 和 css 文件,然后正常加载文件.但是 Internet Explorer 8-10+ 拒绝加载 CSS 文件,原因是CSS 由于 MIME 类型不匹配而被忽略",但是当然不能修改 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://等)
  • 由于MIME 类型不匹配",CSS 无法加载
  • 可在所有其他浏览器中正常运行-_-
  • 不是http://"或localhost"或任何变体

那么,有人知道如何解决这个问题吗?

HTML 加载 CSS:

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 响应标头传送样式表文件,其中包括 textcss 的内容类型.有关详细信息,请参阅 Internet Explorer 中的 MIME 处理更改.",但显然不可能,因为没有通过线路发送标头......

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 textcss. 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 -_-

还可以通过在文件末尾包含 CSS 的 CDN 版本来缓解潜在问题(报告必须在有和没有互联网的情况下工作)

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)

这篇关于Internet Explorer“由于 MIME 类型不匹配,CSS 被忽略"在本地文件上(无服务器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆