Reputation: 433
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.
Upvotes: 0
Views: 4876
Reputation: 1
Oh man, they are trolling you !!! This is a very simple case, no alteration of .htaccess is needed.
Its about the file format. I dont mean the extension, but the way u created the file.
For example: If you get the error on a linux server, i bet you created that file inside of windows explorer or kinda.
The solution is to open the file in notepad++ and goto menu "coding". No u have to know which charset is selected for your webserver. They have to match (fileformat-serverformat) Now u select "Convert into [yourformat]", for me its "UTF8 wo BOM".
Backup your files before u try this.
Upvotes: -2
Reputation: 167182
Can you please try:
AddType application/javascript *.js
I feel that the *
might help.
Might redeclaring the same thing of CSS for JS would help?
<FilesMatch "(\.js)$">
AddType application/javascript .js
Header set Content-Type application/javascript
</FilesMatch>
Upvotes: 1
Reputation: 433
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...
Upvotes: 1
Reputation: 30330
if the CSS rule works, you could replicate it for JavaScript:
<FilesMatch "(\.js)$">
AddType application/javascript .js
Header set Content-Type application/javascript
</FilesMatch>
Upvotes: 1