IE10 local page won't open CSS

倾然丶 夕夏残阳落幕 提交于 2019-12-01 07:17:07

问题


Just installed IE10, and even with a "default reset," when I open a local page (like C:\Documents\index.html), it refuses to load a simple linked stylesheet, with a straightforward call like:

<link href='common.css' type='text/css' rel='stylesheet'>

The console error message is: SEC7113: CSS was ignored due to mime type mismatch

I've hunted through the security settings, but nothing seems to change the behavior.

Viewing the page from the web, there's no problem, of course.

Anyone have a clue?

(FWIW, I'm seeing exactly the same problem on a Win7/64 desktop machine and on an aging little Win7/32 netbook.)

Edit: Here's a simple test case. Save this HTML as index.html in a folder on your PC:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Basic</title>
<link href="common.css" rel="stylesheet" type="text/css">
</head>
<body>
<p>This text should be red.</p>
</body>
</html>

Now save this CSS in the same folder, as common.css:

body {
    color: red;
}

Open index.html with Firefox or Chrome - red text, right? But if I open it with IE10, the text is black - the common.css file is not being loaded.


回答1:


I fixed it easily with a few steps:

  1. Run -> regedit
  2. Open HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.css
  3. Modify: "Content Type" from "text/plain" to "text/css"
  4. Exit regedit

IE 10 now properly reads local CSS files.




回答2:


I found it!

It's OK to use the Control Panel "Default Programs / Associate a file type..." to set .css files to be opened by Notetab Light (my favorite general-purpose text editor). However, if you go into Notetab Light itself and choose View, Options, Associations, and add css to the list, this generates the error I've been seeing.

Apparently, this is producing a registry entry that causes IE10 to be unable to open a local CSS file when it's called from an HTML page. IE9 wasn't afflicted by this (I never had a problem before, and I've been using Notetab Light for ages).




回答3:


Due to MIME type mismatch css was ignored in ie 10. The MIME type can be correct by a utility called FIle TypesMan It is freeware created by NirSoft. It turned out that the MIME type of .css had been changed to text/plain, preventing ie from rendering my styles. using FileTypesMan to change it back to text/css fixed the problem. Download FileTypesMan from the NirSoft site. Use the links near the bottom of the page to select the correct version for your operating system (there are different versions for 32-bit, 64-bit, and Windows 98/ME). Unzip the files to a local folder, and double-click FileTypesMan.exe. When FileTypesMan has finished listing all file types, scroll down in the top pane to find .css. Double-click to edit the settings. Change the value to text/css in the MIME Type field in the dialog box that opens. Click OK. Job done. IE 10 should now behave itself (well, at least as far as rendering style sheets is concerned).



来源:https://stackoverflow.com/questions/15654503/ie10-local-page-wont-open-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!