none
Force IE8 to render in IE8 standard mode

    Question

  • Is there a way to force IE8 to always render a web site in IE8 standard mode?

    I have tried to set the X-UA-Compatible to IE=8 but the local "Display intranet sites in Compability View" overrides it.

    <customHeaders>
      <add name="X-UA-Compatible" value="IE=8" />
    </customHeaders>


    HO
    Friday, October 16, 2009 10:37 AM

All replies

  • http://blogs.msdn.com/ie/archive/2008/10/02/ie8-group-policy.aspx
    It is GP but if you are working for intranet then you should use GP to push settings.


    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
    Visual C++ MVP
    Friday, October 16, 2009 6:46 PM
  • Hi HO,

    Sheng's idea will help, but it will also affect other pages on the local machine.  To control the appearance of individual pages, add an appropriate x-ua-compatible header to the page(s).  Headers in the page override settings, which control behavior when there is no guidance from the page itself, and server headers.

    Thus, adding the following META tag as one of the first lines in the page's section should do the trick.

    <meta http-equiv="x-ua-compatible" content="IE=8">
    The meta element can appear below a title element and other meta elements; however, it must preced other elements in the section.  For more information, please see Defining Document Compatibility.

    Hope this helps...

    -- Lance
    Lance Leonard, Programming Writer, Internet Explorer Developer Content
    • Proposed as answer by ali nouman Wednesday, February 22, 2012 6:07 AM
    Friday, October 16, 2009 8:42 PM
    Moderator
  • GP affects all applications. We have a number of web sites in our organisation and some of them must run in IE8 standard mode, they work in IE8 standard mode and IE7 standard mode but not in Compatibility View.

    We need a way to make sure that some web sites are run in IE8 standard but we can not force it to all applications in our organization.

    Monday, October 19, 2009 8:51 AM
  • Hi there,

    Based on what you've said so far, the best approach would likely be add an x-ua-compatible header to the Web pages of the applications that need to be rendered in IE8 standards mode.  For more information, please see Defining Document Compatibility.

    Hope this helps...

    -- Lance
    Lance Leonard, Programming Writer, Internet Explorer Developer Content
    Monday, October 19, 2009 7:52 PM
    Moderator
  • Hi,

    the header is overridden by the setting 'Display intranet sites in Compability View' in the browser. I want to override 'Display intranet sites in Compability View'.
    Tuesday, October 20, 2009 7:52 AM
  • Hi Nicke11,

    >> the header is overridden by the setting 'Display intranet sites in Compability View' in the browser.

    I'm afraid that's not the way the way IE8 is designed. When provided in the head section of a Web page, the x-ua-compatible header has the last word.

    I confirmed this on my own machine just now using the following markup:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
      <meta http-equiv="content-type" content="text/html; charset=windows-1250">
      <meta http-equiv="x-ua-compatible" content="IE=8">
      <title>META Tag test</title>
      </head>
      <body>
    
    <p>this is a test.</p>
    <button onclick="alert(document.documentMode);">Click me!</button>
    
      </body>
    </html>
    I saved this to my local hard drive, verified that the "Open intranet sites in Compatibility View mode" setting was enabled, and then ran the test. As I expected, the document was displayed in IE8 Standards mode.

    This is the documented way to override the setting.  Are you seeing other results?  If so, how are you performing your test?  There may be a difference in methodology.

    Hope this helps...

    -- Lance
    Lance Leonard, Programming Writer, Internet Explorer Developer Content
    Wednesday, October 21, 2009 12:09 AM
    Moderator
  • Hi thanks for your answer.

    Yes it is correct that document mode is overridden by the header tag, but I want to override browser mode.

    This is a modified version of your example:

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="Test" %>
    
    <!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 runat="server">
       <meta http-equiv="content-type" content="text/html; charset=windows-1250">
      <meta http-equiv="x-ua-compatible" content="IE=8">
      <title>META Tag test</title>
      <script type="text/javascript">
      	/*
      	* Author: Rob Reid
      	* CreateDate: 20-Mar-09
      	* Description: Little helper function to return details about IE 8 and its various compatibility settings either use as it is
      	* or incorporate into a browser object. Remember browser sniffing is not the best way to detect user-settings as spoofing is
      	* very common so use with caution.
      	*/
      	function IEVersion()
      	{
      		var _n = navigator, _w = window, _d = document;
      		var version = "NA";
      		var na = _n.userAgent;
      		var ieDocMode = "NA";
      		var ie8BrowserMode = "NA";
      		// Look for msie and make sure its not opera in disguise
      		if (/msie/i.test(na) && (!_w.opera))
      		{
      			// also check for spoofers by checking known IE objects
      			if (_w.attachEvent && _w.ActiveXObject)
      			{
      				// Get version displayed in UA although if its IE 8 running in 7 or compat mode it will appear as 7
      				version = (na.match(/.+ie\s([\d.]+)/i) || [])[1];
      				// Its IE 8 pretending to be IE 7 or in compat mode              
      				if (parseInt(version) == 7)
      				{
      					// documentMode is only supported in IE 8 so we know if its here its really IE 8
      					if (_d.documentMode)
      					{
      						version = 8; //reset? change if you need to
      						// IE in Compat mode will mention Trident in the useragent
      						if (/trident\/\d/i.test(na))
      						{
      							ie8BrowserMode = "Compat Mode";
      							// if it doesn't then its running in IE 7 mode
      						} else
      						{
      							ie8BrowserMode = "IE 7 Mode";
      						}
      					}
      				} else if (parseInt(version) == 8)
      				{
      					// IE 8 will always have documentMode available
      					if (_d.documentMode) { ie8BrowserMode = "IE 8 Mode"; }
      				}
      				// If we are in IE 8 (any mode) or previous versions of IE we check for the documentMode or compatMode for pre 8 versions                         
      				ieDocMode = (_d.documentMode) ? _d.documentMode : (_d.compatMode && _d.compatMode == "CSS1Compat") ? 7 : 5; //default to quirks mode IE5                                                                      
      			}
      		}
    
      		return {
      			"UserAgent": na,
      			"Version": version,
      			"BrowserMode": ie8BrowserMode,
      			"DocMode": ieDocMode
      		}
      	}
    
      	function DisplayInfo()
      	{
      		var browserInfo = IEVersion();
      		alert('UserAgent: ' + browserInfo.UserAgent + '\nVersion: ' + browserInfo.Version + '\nBrowserMode: ' + browserInfo.BrowserMode + '\nDocMode: ' + browserInfo.DocMode);
      	}
    
      </script>
    </head>
    <body>
        <p>this is a test.</p>
    	<button onclick="DisplayInfo();">Click me!</button>
      
    </html>
    

    Try to check 'Display intranet sites in Compability View' and run the test page. For me the result is that the page renders in compat mode. You can also see this by using the IE8 developer tool (press F12).

    I want to override 'Display intranet sites in Compability View'.
    Wednesday, October 21, 2009 7:37 AM
  • Hi Lance Leonard,

    I tried your example, and document.documentMode actually is 8.

    However, IE still renders the page in IE 8 Compatibility View: I can see it in the IE Developer Tools window. Could you please check the browser mode using the Developer Tools? Thanks,

     Andrea
    Wednesday, January 20, 2010 3:16 PM
  • I realize it's been three years since this post, but here's an update that I think solves the mystery.  I ran into this same problem while working on my office intranet. 

    IE 8 will ignore the x-ua-compatible setting if it comes after the stylesheets.  In order for IE to acknowledge the meta setting, put it at the top.

    Just posting this for anybody that landed here from Google and can't figure out why this isn't working.


    • Edited by ThndrChld2 Tuesday, November 13, 2012 9:45 PM
    Tuesday, November 13, 2012 9:44 PM
  • Hi, 

    I am facing this issue and really pissed off. I have added your code and see that Browser mode is IE8 and Doc Mode is 9. 

    I have added <DocType> and IE=Emulate8 before to css style call. But still Doc Mode is 9.

    Also I have unchecked this - "Compatibility view settings" - "Display intranet sites in Compatibility View"

    Please help me!

    I need to display html inside a page viewer webpart and since Iframe is not supported in IE9, I have to force browser mode to IE8. 

    I have also tried <Object> and <Embed> but even this has problem with IE9


    • Edited by Anu4smile Tuesday, August 19, 2014 6:55 AM
    Tuesday, August 19, 2014 6:53 AM
  • Thank u  ThndrChld2..this one worked for me..

    Tuesday, September 09, 2014 6:52 AM