简体   繁体   English

Chrome表示“资源被解释为脚本,但使用MIME类型的文本/纯文本传输。”,不带服务器

[英]Chrome says “Resource interpreted as script but transferred with MIME type text/plain.”, without server

This problem even arises, when there is no server access whatsoever. 当没有任何服务器访问权限时,甚至会出现此问题。 index.html is just accessing some locally stored JavaScript file: index.html只是访问一些本地存储的JavaScript文件:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <script src="timeline.js"></script>
</head>

<body>
   <p>The Body</p>
</body>
</html>

When displayed in the browser, Chrome says: 在浏览器中显示时,Chrome会显示:

Resource interpreted as Script but transferred with MIME type text/plain:  
file:///D:/Workspace/timeline/examples/engel-timeline/timelineReusable.v0.0/timeline.js". 

How can I suppress this message? 如何隐藏此消息? (Adding a 'content-type' doesn't help!) (添加“内容类型”无济于事!)

I believe the reason for this is that your script is being loaded locally from your computer. 我相信这是因为您的脚本是从计算机本地加载的。 It's directly accessing the file, so there are no request headers here, meaning there will be no MIME type that comes with your JS file. 它是直接访问文件,因此这里没有请求标头,这意味着您的JS文件将没有MIME类型。

If you upload your file on the Internet, then this will be fixed because it uses a different protocol (HTTP). 如果您在Internet上上传文件,则该问题将得到解决,因为它使用其他协议(HTTP)。

This problem should only end up happening when there is no server. 仅当没有服务器时,此问题才最终会发生。 If there is a server, then make sure you're using the server's URL, like http://localhost:80/timeline.js . 如果有服务器,请确保使用服务器的URL,例如http://localhost:80/timeline.js And if that still is giving you a problem, then your server's MIME types need to be configured (though it's just a JavaScript file, so that shouldn't be a problem). 并且,如果这仍然给您带来问题,则需要配置服务器的MIME类型(尽管它只是一个JavaScript文件,所以这不应该成为问题)。

尝试打开regedit:HKEY_CLASSES_ROOT \\ .js,然后更改或添加值为“ text / javascript”的字符串“ Content Type”

The error also arises in this situation: 在这种情况下也会出现错误:

<script type="text/javascript" src="/livehelp/livehelp_js.php>

indicating that Chrome is the problem, the code is good. 表明Chrome是问题所在,代码很好。 Chrome is wrongly blocking a script sent in a php file. Chrome错误地阻止了php文件中发送的脚本。 The script is not blocked in other browsers except IE 11 and only when Apache directive Header set X-Content-Type-Options: "nosniff" is set. 该脚本在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.

相关问题 Chrome错误-资源被解释为脚本,但以MIME类型的文本/纯文本传输 - Chrome Error - Resource interpreted as Script but transferred with MIME type text/plain Chrome说“资源解释为样式表,但使用MIME类型text / html传输” - Chrome says “Resource interpreted as Stylesheet but transferred with MIME type text/html” js警告:资源被解释为脚本,但以MIME类型text / plain传输 - js warning: Resource interpreted as Script but transferred with MIME type text/plain 资源解释为脚本,但使用MIME类型text / plain传输 - 用于本地文件 - Resource interpreted as Script but transferred with MIME type text/plain - for local file Cordova插件错误:资源被解释为脚本,但以MIME类型的文本/纯文本传输 - Cordova plugin error: Resource interpreted as Script but transferred with MIME type text/plain ajax错误:资源被解释为脚本,但以MIME类型text / json传输: - ajax error: Resource interpreted as Script but transferred with MIME type text/json: 资源被解释为脚本,但在单个站点上以MIME类型text / html传输 - Resource interpreted as Script but transferred with MIME type text/html on individual site “资源被解释为脚本,但使用MIME类型text / html进行传输。” - “Resource interpreted as script but transferred with MIME type text/html.” 返回json时,Chrome扩展程序错误:资源被解释为脚本,但以MIME类型text / json传输 - Chrome Extension error when returning json: Resource interpreted as Script but transferred with MIME type text/json 资源被解释为脚本,但以MIME类型text / x-js传输 - Resource interpreted as Script but transferred with MIME type text/x-js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM