Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC App causing IE9 to use older standards

When I tested a new asp.net MVC app I created on another machine the layout was incorrect and seemed strange in IE9. When looking at Developer Tools the Mode/Standards were set to older versions and even Compatibility Mode. I changed this back to IE9 and was ok again.

But then when I reopened the site it had set these values back again, is there some default for these that keep overriding or is my app for some reason causing these values to change to older versions?

like image 380
user1166905 Avatar asked Nov 22 '12 20:11

user1166905


2 Answers

There is some mechanism, which IE browser family uses to guess what rendering mode would be the best. There is more reading about this topic:

X-UA-Compatible is set to IE=edge, but it still doesn't stop Compatibility Mode

So there is a way how to say, which IE version you are targeting. Put this html tag as the first (really the first) in the <head> element after the <title>

<!DOCTYPE html>
<html>
  <head>
    <title>My Web</title>
    <meta http-equiv="X-UA-Compatible" content="IE=100" >
    ...

content should be contain="IE=8" if you are targeting IE 8.0, IE=100 will work for IE 9.0++.

I've read that this behavior won't work on intranet, but my experinece is different. The point is that that <meta> element MUST be the first! The first means, no comment before. Nothing just the first one after the title.

For example, I do some investigation on the server side in code to check what version it is, and put the meta related to the browser - as the first element

like image 150
Radim Köhler Avatar answered Oct 21 '22 22:10

Radim Köhler


As an extra note, it's possible to save compatibility overrides to your local browser when testing.

From (http://answers.microsoft.com/en-us/ie/forum/ie9-windows_7/ie9-always-rendering-pages-in-ie7-compatibility/c0177b44-3950-e011-8dfc-68b599b31bf5):

Step 1: Let’s turn off compatibility view and check.

a. Open internet explorer.

b. Click on Alt key on the keyboard. Now click on Tools in menu bar.

c. Select Compatibility View Settings.

d. Remove the check mark for Display all websites in Compatibility View and close the Compatibility View Settings window.

Step 2: Reset internet explorer settings and check.

Refer: http://support.microsoft.com/kb/923737 (This article may also be used for internet explorer 9)

like image 25
Steve de Niese Avatar answered Oct 21 '22 21:10

Steve de Niese