![](/img/trans.png)
[英]Chrome Error - Resource interpreted as Script but transferred with MIME type text/plain
[英]Chrome says “Resource interpreted as script but transferred with MIME type text/plain.”, without server
当没有任何服务器访问权限时,甚至会出现此问题。 index.html只是访问一些本地存储的JavaScript文件:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="timeline.js"></script>
</head>
<body>
<p>The Body</p>
</body>
</html>
在浏览器中显示时,Chrome会显示:
Resource interpreted as Script but transferred with MIME type text/plain:
file:///D:/Workspace/timeline/examples/engel-timeline/timelineReusable.v0.0/timeline.js".
如何隐藏此消息? (添加“内容类型”无济于事!)
我相信这是因为您的脚本是从计算机本地加载的。 它是直接访问文件,因此这里没有请求标头,这意味着您的JS文件将没有MIME类型。
如果您在Internet上上传文件,则该问题将得到解决,因为它使用其他协议(HTTP)。
仅当没有服务器时,此问题才最终会发生。 如果有服务器,请确保使用服务器的URL,例如http://localhost:80/timeline.js
。 并且,如果这仍然给您带来问题,则需要配置服务器的MIME类型(尽管它只是一个JavaScript文件,所以这不应该成为问题)。
尝试打开regedit:HKEY_CLASSES_ROOT \\ .js,然后更改或添加值为“ text / javascript”的字符串“ Content Type”
在这种情况下也会出现错误:
<script type="text/javascript" src="/livehelp/livehelp_js.php>
表明Chrome是问题所在,代码很好。 Chrome错误地阻止了php文件中发送的脚本。 该脚本在IE 11以外的其他浏览器中没有被阻止,只有在Header set X-Content-Type-Options: "nosniff"
Apache指令Header set X-Content-Type-Options: "nosniff"
时,该脚本才会被阻止。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.