Cannot Get FontAwesome Working in IE 11 with MVC 5 - html

I have a new MVC 5 Project and I am trying to get FontAwesome to display icons from the _Layout page. It works fine in Chrome, Firefox, and even the Page Inspector in Visual Studio. When I launch the site in IE 11, it just shows a blank space.
What I've tried so far:
Making sure the font-awesome.css and fonts are being downloaded to the browser
Checking the paths to the directory where the fonts exists is correct
Loading from the BundleConfig and just putting the links directly on the Layout page
Installing FontAwesome using Nuget and tried an Nuget Html Helper for FontAwesome
Tried added MIME types for the fonts to the web.config
Tried using CDNs and Fully qualified paths instead of relative links
Tried several variations of the markup
Validated no errors in the Console or 404s in the Network Debugger
I'm not sure what else I can try and feel like I've spent WAAAY to much time just trying to get some icons to work. It's just frustrating because the site looks really good in Chrome and Firefox.
I am using a Template I downloaded from WrapBootstrap, but their examples work in IE 11, and I've tried to mimick their markup as best I can.
Below is the markup in the Layout page I am using and this comes directly from their Template and it works in FF/Chrome.
<i class="icon-dashboard"></i>
and I tried
<i class="fa fa-dashboard"></i>
Any guidance on troubleshooting would be appreciated.

It's not really that complicated. If it works in Chrome and Firefox it will work in IE11. My guess is that you've either switched the rendering engine to IE7 at some point and forgot, accidentally clicked the compatibility mode button (which renders as IE7), or otherwise are working in compatibility mode (depending on your local or GP settings, if this is a work machine, compatibility mode may be the default for local and/or intranet sites).

I just had this issue but found that it was actually caused by the fact the font files reside on a different subdomain. Adding an Access-Control-Allow-Origin header when serving the fonts solves the problem.
Apache .htaccess snippet
<FilesMatch "\.(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
nginx virtual host file snippet
location ~* \.(eot|otf|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
}
More information can be found here (original source for snippets).

Another possibility (which I just spend 4 hours debugging) is that IE-11 is falling back to an older document compatibility mode without your knowledge. The thing to do is make sure the auto-detected target really reads "Edge". In my case it was blank.
The files were downloading.
The MIME types and headers were right.
My document had the right compatibility meta tag set.
I could surf just fine.
The console showed no JS errors (or errors of any kind).
Yet still no Fontawesome.
Turns out if your HD is running low on space as my VM was and the available temp cache falls below a certain size, IE silently reverts to showing all websites in compatibility mode (no matter what your settings are in regard to when to use compatibility mode).

Try this in your web.config. It should work for Font-awesome 4.7:
<system.webServer>
<staticContent>
<remove fileExtension=".svg" />
<remove fileExtension=".eot" />
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<remove fileExtension=".otf" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="font/woff2" />
<mimeMap fileExtension=".otf" mimeType="application/font-sfnt" />
</staticContent>
</system.webServer>

Related

Why font-awesome icons are not displayed in Mozilla firefox? [duplicate]

I am having an issue with using a font accessed via a relative URL.
#font-face {
font-family: 'ElegantIcons';
src:url('../src_main/fonts/ElegantIcons.eot');
src:url('../src_main/fonts/ElegantIcons.ttf') format('truetype'),
url('../src_main/fonts/ElegantIcons.svg#ElegantIcons') format('svg'),
url('../src_main/fonts/ElegantIcons.woff') format('woff'),
url('../src_main/fonts/ElegantIcons.eot?#iefix') format('embedded-opentype');
font-weight: normal;
font-style: normal;
}
When I access the web page the font doesn't work and in the console I get this:
downloadable font: download failed (font-family: "ElegantIcons" style:normal weight:normal stretch:normal src index:1): status=2147500037
source: file:///...snipped.../src_main/fonts/ElegantIcons.woff # file:///...snipped.../src_poke/fonts-style.css
Accessing the file by copying/pasting the URL into the browser address bar shows that it is the correct URL as I can download the font.
A hat tip to Jonathan Kew's response on a relevant mozilla bugzilla entry:
I believe this is working as designed. AIUI, the issue here is that
for a page loaded from a file:// URI, only files in (or below) the
same directory of the filesystem are considered to be "same origin",
and so putting the font in a different subtree (../font/) means it
will be blocked by security policy restrictions.
You can relax this by setting security.fileuri.strict_origin_policy to
false in about:config, but as this gives the page access to your
entire local filesystem, it's something to be used with caution.
To summarise, the "fix" without re-arranging your files:
Open about:config
Set security.fileuri.strict_origin_policy to false
Beware of the security implications
The best way is, however, to make sure any resources are accessible without going back up the file system first.
Note: the origin policy is calculated based on the html, NOT the css file! So a font file right besides an css file might not work, which is very confusing. (At least this is what I thought was the case with Firefox!)
Follow ups:
eradman comments:
It's the other way around: relative paths are relative to the CSS file.
chrylis responds:
You'd think that, but the actual code in Firefox doesn't seem to agree.
For local file we have to use local()
For external we have to use url()
According to the document https://developer.mozilla.org/en-US/docs/Web/CSS/#font-face
For example
src:local('../src_main/fonts/ElegantIcons.eot');
#CharlesGoodwin #eradman Actually, both statements about the origin seem true except that they probably talk about two different things: same-origin check is based on the originating HTML file, while relative URLs for font faces are resolved relative to the CSS file containing the #font-face rule.
Moreover, originating HTML file is not the file that uses the font. I have the following local file structure.
<base-directory>/index.htm
<base-directory>/ARPLS/toc.htm
<base-directory>/dcommon/css/fonts.css
<base-directory>/dcommon/fonts/myfont.woff
fonts.css references myfont.css via url(../fonts/myfont.woff) and toc.htm reference fonts.css via <link ... href="../dcommon/css/fonts.css">. index.htm has a hyperlink to toc.htm.
Now, I have bookmarked both index.htm and toc.htm. If I use the index.htm bookmark, the font is rendered correctly. If I use the toc.htm bookmark, the font fails to load. I guess this is because myfont.woff is in a sub-directory of the directory containing index.htm but not of the directory containing toc.htm.
Observed in Firefox 38.6.
Try adding this to your web.config
<system.webServer>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>
Usually this happens when the original source css has relative font face declaration like so ../fonts/some-font.woff, and you compile that source CSS into bundle.css which resides at some other path. So that way you lose the path to font.
I have been running into this issue since the latest update (about 1.5 weeks ago). This thread specifically, plus the comments in Bugzilla helped me to understand the problem as a security feature. The solution that I found (eventually) was to take my Firefox preferences off of "strict" security and set to standard/default. "Strict" even says it will break some sites, so I think that this goes to the above point that this issue is by-design.

Is there any way to force the browser to NOT use Enterprise Mode in IE11?

I'm trying to develop a website that uses features not compatible with IE7/8, but the company-standard browser (IE11) we all use forces my page to use Enterprise Mode (which is effectively rendering with IE7/8).
Everything I've seen talks about fixing it on a high-level "site list" within the company, or making a browser not use Enterprise Mode locally (by modifying registry entries). One internally suggested approach was to use the meta tag:
<meta http-equiv="X-UA-Compatible" content="IE=11" />
...but it didn't work.
Is there any way I can force the client, from the server-side, to not use Enterprise mode?
Note: We are using Websphere 8.5 servers.
This has worked for me - forcing the X-UA compatible header from IIS by modifying the application's web.config file as below (if you are using IIS as your webserver).
<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="X-UA-Compatible" /> <!-- in case it was already set -->
<add name="X-UA-Compatible" value="IE=edge" />
</customHeaders>
</httpProtocol>
</system.webServer>

IE 10 and 11 renders in IE 7 mode on intranet site.

I am trying to get IE to render on the latest version for intranet sites, but it keeps defaulting to IE 7 for compatibility. I have this in my Web.config and it still does not work. A meta tag will not work because this is an intranet site (), and I have tried it, also. I have the following in my web.config:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=edge" />
</customHeaders>
</httpProtocol>
</system.webServer>
I would appreciate any suggestions. Also, I do know that you can turn off the compatibility mode in IE settings but this would not work for me as I have 1000s of users that would have to do this individually, which would not be ideal and would be my last choice on how to handle the situation.
We have this issue in the organisation that I'm currently working for.
Sorry to be the bearer of bad news but, from what we've discovered, the 'fallback' to IE7 is a network wide policy set by the IT department. As we all know, getting things like this changed is like getting blood from a stone !
Every set-up is different however so you could try this:
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
Directly after your opening 'head' tag...

HTML5 doctype commented out for IE10 PP2 but not Chrome

I have a simple HTML5 page.
<!DOCTYPE html>
<html>
Test
</html>
On my local IIS, IE 10 PP2 and Chrome return this page fine. The doctype is in the header.
But when I serve this page up from our IIS 7.5 on a remote server, Chrome works but IE 10 PP2 has the doctype commented out in the response.
<!-- DOCTYPE html -->
Is my server missing an update that would cause this to happen?
(I made simple test pages with VS 2012 with real HTML 5 features like the "placeholder" attribute that work locally in both IE 10 and Chrome, bot only in Chrome from our server.)
Thanks for any help.
Adding this to my web.config stopped IE from rendering in compatibility mode on my local intranet.
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=edge" />
</customHeaders>
</httpProtocol>
</system.webServer>

SVG as a CSS background

I've been trying to get a simple SVG rectangle to work as a background in IE9 or FF4 and neither is working for me. Here's my code:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div style="height:99px;background-image: url('bar.svg')"></div>
<iframe src="bar.svg" height="99px"></iframe>
</body>
</html>
The iframe shows the graphic but the div does not. Any ideas where I may be going wrong?
I found a working example here:
But I can't make it work myself :(
It's been driving me crazy.
Thanks for any help.
Thanks everyone for the help. It actually was a web server problem where the wrong MIME type for SVG was being served & that made the browsers fail to render correctly.
Here's what fixed it for me.
1st I switched from VS 2010's built-in web server to IIS Express. Then in my web config I added:
<system.webServer>
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
Now everything works correctly.
I was having the same problem in Joomla! 2.5 running on Godaddy Linux server.
After intense research here is how I fixed the problem:
Go to the root directory of your Joomla install and locate the .htaccess file (or htaccess.txt if it is not already setup)
Now add these lines to the file:
AddType image/svg+xml svg
AddType image/svg+xml svgz
Rest, use the standard CSS and HTML properties to render your SVG file.
Does this jsfiddle work for you?
http://jsfiddle.net/B3mnk/embedded/result/
fwiw, I've added a background size to make it nice 'n big.
Some articles with examples:
https://jwatt.org/svg/demos/xhtml-with-inline-svg.xhtml
http://helephant.com/2009/08/svg-images-as-css-backgrounds/
https://developer.mozilla.org/en/svg_in_html_introduction
http://www.broken-links.com/2010/06/08/using-svg-in-background-image/ - This one has a fallback to .png near the bottom of the article.
Reported as a bug in Firefox:
https://bugzilla.mozilla.org/show_bug.cgi?id=231179