Is there a way to force IE8 into IE7 compatibility mode using .NET or Javascript?

- 29,228
- 19
- 111
- 160

- 17,201
- 24
- 97
- 123
-
1Also, can I accomplish this using IIS settings? – Bryan Jun 18 '09 at 19:37
-
10I guess I could see the value in this for old pages, but PLEASE don't create new pages that depend on IE7... let the beast die. – TM. Jul 07 '09 at 13:04
-
IE8 has bugs that IE7 doesn't have and that go away when switching to compatibility mode: http://stackoverflow.com/questions/1070178/why-does-ie8-add-bottom-border-on-my-image-anchor-tag My site is affected by that bug, and I'd rather tell IE8 to display it correctly like IE7 and every other browser does by adding one line to my .htaccess file, than to add a browser-specific workaround to my actual pages. – Jan Goyvaerts Jul 23 '09 at 07:44
-
4Adding the X-UA-Compatible header also removes the "compatibility view" button, which looks more professional IMO. The user shouldn't have to figure out which mode is best for your site. It's the webmaster's job to make the site support all major browsers. – Jan Goyvaerts Jul 23 '09 at 07:46
9 Answers
If you add this to your meta tags:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
IE8 will render the page like IE7.

- 23,496
- 29
- 102
- 138
-
22You're right - but try to add it immediately after the opening tag. I had problems when it was further down the page. – John McCollum Jun 18 '09 at 19:24
-
1What if I don't to add this line to every aspx page on my site. Can I do it with IIS? – Bryan Jun 18 '09 at 19:29
-
6
-
2
-
4
-
The other one I like to use as my code works the same for IE 8,9,10 is: `` . With IE=Edge it will tell IE to use the latest version all the time (as long as you are okay with this...). – SimonSays Nov 10 '12 at 12:54
You can do it in the web.config
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=7"/>
</customHeaders>
</httpProtocol>
I have better results with this over the above solutions. Not sure why this wasn't given as a solution. :)

- 319
- 3
- 2
-
+1 Good solution, if you're using IIS7 - http://www.iis.net/ConfigReference/system.webServer/httpProtocol – Ian Robinson Nov 16 '10 at 16:02
-
Great solution when you can't change the content of the page or change the page headers directly. – Philip Hanson Apr 15 '11 at 18:38
-
I think HTTP headers override any meta tags, so they should be the preferred solution if you have the option. – Matthew Jul 17 '15 at 11:21
I might have found it now. http://blog.lroot.com/articles/the-ie7-compatibility-tag-force-ie8-to-use-the-ie7-rendering-mode/
The site says adding this meta tag:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
or adding this to .htaccess
Header set X-UA-Compatible: IE=EmulateIE7

- 85,954
- 40
- 175
- 219

- 17,201
- 24
- 97
- 123
There is an HTTP header you can set that will force IE8 to use IE7-compatibility mode.

- 9,811
- 2
- 32
- 54
-
1I couldn't get the meta tag to work, but adding this header did the job. Thanks! – swatkins Aug 02 '12 at 19:32
its even simpler than that. Using HTML you can just add this metatag to your page (first thing on the page):
<meta http-equiv="X-UA-Compatible" content="IE=7" />
If you wanted to do it using.net, you just have to send your http request with that meta information in the header. This would require a page refresh to work though.
Also, you can look at a similar question here: Compatibility Mode in IE8 using VBScript

- 1
- 1

- 1,656
- 2
- 19
- 34
one more if you want to switch IE 8 page render in IE 8 standard mode
<meta http-equiv="X-UA-Compatible" content="IE=100" /> <!-- IE8 mode -->

- 572
- 6
- 21
A note to this:
IE 8.0s emulation only promises to display the page the same. There are subtle differences that might cause functionality to break. I recently had a problem with just that. Where IE 7.0 uses a javascript wrapper-function called "anonymous()" in IE 8.0 the wrapper was named differently.
So do not expect things like JavaScript to "just work", because you turn on emulation.

- 99
- 1
- 1
- 6
-
5Writing code that depends on the "name" of an anonymous function is not a reliable dependency to take, regardless of browser version. – EricLaw Jul 14 '09 at 14:58
This can be done in IIS: http://weblogs.asp.net/joelvarty/archive/2009/03/23/force-ie7-compatibility-mode-in-ie8-with-iis-settings.aspx
Read the comments as well: Wednesday, April 01, 2009 8:57 AM by John Moore
A quick follow-up. This worked great for my site as long as I use the IE=EmulateIE7 value. Trying to use the IE=7 resulted in my site essentially hanging when run on IE8.

- 11
- 1
my code has this tag
meta http-equiv="X-UA-Compatible" content="IE=7" />
is there a way where i can skip this tag and yet layouts get displayed well and fine using that tag the display will work upto IE 7 but i want to run it wel in further versions...

- 67
- 9