简体   繁体   中英

IE8 Document mode not being set correctly

I have a website, where IIS sends the following in the header (which is correct for the overall site):

 X-UA-Compatible: IE=Edge

However, on a specific page, I have at the very top of my <head> section the following:

<!--[if lt IE 9]>
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
<![endif]-->

This is being interpreted correctly by IE8, as it shows up at the top of the when I view the page source. However, it never changes my Document Mode from "IE8 Standards" to "IE7 Standards." The Browser Mode is in IE8 Compatibility View by default(it's an intranet site), but even in normal IE8 mode, it still has the same Document Mode issues.

I thought that having the meta tag on the page overrides whatever was sent in the initial header from the server. Is there anything else I could be doing to change the document mode for this one page?

EDIT: I can force IE7 document mode if I place the following in my Page_Load of my aspx page Response.AddHeader("X-UA-Compatible", "IE=7"); so I now have this header show up after the IE=Edge header, so only this second one is interpreted. This doesn't actually solve my issue though, because the meta tag above has the advantage of not being used in IE9 or IE10, and some of the niceties of the page disappear when forcing to IE7 document mode. I just specifically need this to work for IE8 and older.

Also, if I remove the conditional CSS, it appears to get the document mode correct. So is it possible that conditional CSS executes after the page loads, and if so, how do I fix it to make IE7 document mode only show up for IE8 and earlier browsers?

Are you sure you have the order correct? I just tried this page that I found HERE and my browser defaults to "IE7 standards".

<html>
<head>      
  <!--[if lt IE 9]>
  <meta http-equiv="X-UA-Compatible" content="IE=7" >
  <![endif]-->
  <title>My webpage</title>
</head>
<body>
  <p>Content goes here.</p>
</body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM