Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internet Explorer "CSS was ignored due to mime type mismatch" on local files (no server)

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.

So in short:

  • Local files (C:\,file://,etc)
  • CSS Won't load due to "MIME type mismatch"
  • Works in every other browser without issue -_-
  • Not "http://" or "localhost" or any variant

So, does anyone have any idea's on a work-around for this issue?

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>

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 text\css. See MIME-Handling Changes in Internet Explorer for more information.", but obviously impossible, as no header's are being sent across the wire......

like image 807
Mattisdada Avatar asked May 10 '13 01:05

Mattisdada


2 Answers

I'm on Windows 8.1 using IE11 with the same issue. This is how I fixed it:

  1. On your computer search for "regedit.exe" (go to the start menu and click on the search button on the top-right corner of the screen).
  2. Once regedit opens up, on the left column click on "HKEY_CLASSES_ROOT" and then on ".css"
  3. On the right column double-click on "Content Type". This will open up a dialog box.
  4. In the dialog box change "value data" to "text/css".
  5. Click "Ok" and that's it.

I hope this helps other people out there.

like image 82
user3781952 Avatar answered Nov 01 '22 19:11

user3781952


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

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)

like image 35
Mattisdada Avatar answered Nov 01 '22 19:11

Mattisdada