Pushpa Raj
Pushpa Raj

Reputation: 89

Firefox: The stylesheet was not loaded because its MIME type, “text/html”, is not “text/css”

Firefox is giving the following error on console:

The stylesheet https://example.com/search? was not loaded because its MIME type, “text/html”, is not “text/css”.

I am displaying an external website in an iframe, and i do not have access to the site to fix the mime type issue. My problem is that the above error halts the JS execution and my other necessary javascript code for the page is not executed. I went through other similar topic on stackoverflow but all enforce to fix the mime type or invalid css.

It works on all other major browsers however it does not work on firefox desktop and firefox mobile. How can i disable this error or prevent it halting my js execution ?

Upvotes: 2

Views: 2152

Answers (1)

Gintare Statkute
Gintare Statkute

Reputation: 687

For me the solution/reason was the http versus https

url : https://localhost/xx for the link http://localhost/xx was causing this error.

As it was the localhost, i have changed url http://localhost/xx which loaded style-sheet <link rel="stylesheet" type="text/css" href="http://localhost/xx.css" /> with the warning: loaded as CSS even though its MIME type, "text/html", is not "text/css" It is not recommended on server, only on localhost machine.

Using https for url and stylesheet url https://localhost/xx

<link rel="stylesheet" type="text/css" href="https://localhost/xx.css" />

gives the same warning loaded as CSS even though its MIME type, "text/html", is not "text/css"

Upvotes: 1

Related Questions