Disable Compatibility View Through Code In IE?

22,986

Solution 1

Here's the documentation you are looking for: http://msdn.microsoft.com/en-us/library/cc288325(v=vs.85).aspx

Include this and IE will render as in IE9 mode:

<meta http-equiv="X-UA-Compatible" content="IE=9" />

Solution 2

By default, IE will render in compatibility mode for websites on the same subnet as the client. You can fix this by either turning off this feature in IE by going to Tools->Compatibility View Settings and unchecking Display Intranet sites in compatibility mode, or by including the meta tag that Sologoub mentioned.

Solution 3

I have this issure too. And I found a solution :

insert meta tag in header HTML:

<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>

and set the equivalant header:

header('X-UA-Compatible: IE=Edge');

Or if you use Zend Framework (or any framework for that matter), something like this will do Zend_Controller_Front::getInstance()->getResponse()->setHeader('X-UA-Compatible', 'IE=Edge');

solution in this link :

http://www.enrise.com/2012/03/internet-explorer-9-compatibility-view-list/

Thanks.

Solution 4

Sometimes you need to be a bit more comprehensive so that you target all the possible user overrides. Certainly for single-page apps like Meteor:

<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE; Chrome=1" />

Hope this helps.

Share:
22,986
Aaron Brewer
Author by

Aaron Brewer

Updated on August 05, 2022

Comments

  • Aaron Brewer
    Aaron Brewer almost 2 years

    I for some reason am calling a doctype preferably XHTML 1.0 Transitional, and for some reason every single time I open it in Internet Explorer I get...

    Browser Mode: IE9 Compat View
    Document Mode: IE7 Standards

    I'll even include what my doctype looks like with the beginning of my head tags:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
    

    And yes, I do close <body> and <html>.

    Any ideas?

    • Jared Farrish
      Jared Farrish over 12 years
      Have you checked the markup itself actually conforms using a validator?
    • Brigand
      Brigand over 12 years
      Take a look at this Wikipedia article. I think this is the correct way to do it. Does your html element look like the first example's?
    • Brigand
      Brigand over 12 years
      @JaredFarrish, good idea. This is the W3C's validator. That doesn't mean MS will conform to it though. Paste your whole page in the direct input, or give it a link.
    • Aaron Brewer
      Aaron Brewer over 12 years
      @JaredFarrish: Yes, I have, via W3C.
  • Erik Funkenbusch
    Erik Funkenbusch over 12 years
    better yet is IE=Edge, this will make sure it renders in the most standards compliant mode in future versions.
  • Aaron Brewer
    Aaron Brewer over 12 years
    @Sologoub: Awesome, this is what I want to do, but how do I know that if the Web-Page is viewed in Internet Explorer 7 it will view it in Internet Explorer 7 standards? Same with Internet Explorer 8? And even later versions of Internet Explorer? Thanks! :)
  • Erik Funkenbusch
    Erik Funkenbusch over 12 years
    @AaronBrewer - apparently you didn't read the last part of my message, which suggested using the meta tag.
  • Erik Funkenbusch
    Erik Funkenbusch over 12 years
    @AaronBrewer - if you use the IE=Edge I mentioned, that will be the case.
  • Aaron Brewer
    Aaron Brewer over 12 years
    I apologize, I didn't comprehend your answer well enough. Thank you so much for the help!
  • Moo-Juice
    Moo-Juice over 10 years
    Just came across this answer trying to solve the same thing. Any idea why IE behaviour defaults this way? We have 100s of PCs that have been recently upgraded to Windows 7, and I can foresee some issues.
  • Erik Funkenbusch
    Erik Funkenbusch over 10 years
    @Moo-Juice - this was not introduced in Windows 7. It was introduced in Vista, with IE7. The reason is that, at the time, most corporate customers needed their sites to default to compatibility view to work correctly. There is also a group policy setting that can control this. See social.technet.microsoft.com/Forums/ie/en-US/…
  • daniloquio
    daniloquio over 10 years
    I suggest that @Sologoub edits the answer including the edge option and closing the meta tag with />
  • Erik Funkenbusch
    Erik Funkenbusch over 10 years
    meta tags should only be closed if you're using xhtml, in html they should be unclosed (although html5 allows both).
  • radbyx
    radbyx over 7 years
    Nice knowing who you specify multiple versions.
  • Kyle Vassella
    Kyle Vassella over 5 years
    I'm using IE11 and facing this issue - the meta tag for 'IE=Edge' is still not fixing this problem. Hoping I can find a solution without requiring every user of the app to go in and change this setting.