dongwo8827523 2014-10-16 09:30
浏览 609
已采纳

Chrome错误 - 资源解释为脚本但使用MIME类型text / plain传输

I have tried ALL the solutions on many pages with no success. I did not have Visual Studio installed so no registry tweaks needed there. Adding in header tags into PHP did not work for me. It seemed it was affecting my .css files and also my .js files. Firefox would only show the .css errors and also show NO style rules at all.

The exact errors are...

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://newpcs.perrycs.com/css/bootstrap-theme-cerulean.css".

and

Resource interpreted as Script but transferred with MIME type text/html: "http://newpcs.perrycs.com/js/bootstrap.js".

UPDATE: I found a fix from my web host IT. They said to add the following code to my .htaccess file and it DID solve the .css but not the .js in Chrome. Here is the code they had me put in...

Options -Indexes

<FilesMatch "(\.css)$"> 
   AddType text/css .css 
   Header set Content-Type text/css 
</FilesMatch>

AddType application/x-javascript .js

It fixed it for the .css but not the .js

I have also tried...

AddType application/javascript .js

with no luck. I"m waiting to hear back from IT again but in the meantime I'll keep looking. I know the .js works.. it's just an OCD thing ... I don't want ANY errors in Chrome.

  • 写回答

4条回答 默认 最新

  • dongping4901 2014-10-16 09:38
    关注

    While I was waiting to get help from IT. I previously asked them... should I do the same with the .js as with the .css and I was told NO... the only thing you need for .js is

    AddType application/x-javascript .js
    

    That's what they gave me... and it did NOT solve my problem. I also tried...

    AddType application/javascript .js
    

    and that did NOT work as well.

    So... I thought I would try the thing I was told not to try. Here is my final .htaccess file.

    Options -Indexes
    
    <FilesMatch "(\.css)$"> 
       AddType text/css .css 
       Header set Content-Type text/css 
    </FilesMatch>
    
    <FilesMatch "(\.js)$"> 
       AddType application/javascript .js
       Header set Content-Type application/javascript 
    </FilesMatch>
    

    and... it WORKS! No more errors in Chrome. I have no idea about .htaccess files... I thought... well, it didn't work with the .js after all... so what harm can come from this? Anyone want to help me out and tell me that what I have done is a bad thing? Any bad side effects?

    I should also note... there was never a problem in the past with my .css files or my .js files. It seems to have happened after they upgraded something but I do not know for sure as I wasn't looking into the problem right when I noticed my CSS styles disappeared from my side projects. Well, as long as it works...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥20 为什么我写出来的绘图程序是这样的,有没有lao哥改一下
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号