简体   繁体   中英

Using <meta http-equiv=“X-UA-Compatible” content=“IE=8” /> mode in sites good practice?

I've recently discovered the joys of adding the following into the header of sites:

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

Websites just work, CSS is beautiful and life is good. But I am slightly concerned about how good a practice this is?

What about an really old computer that has IE7 installed? Can that version of IE7 actually access the IE8 standards mode?

The short answer to the last part of your question is no: IE7 can't be made to work in IE8 mode. So using the X-UA-Compatible header won't force older versions of IE to think they're a newer version. (if that worked, we could all just start using content="IE-10" and be done with worrying about backward compatibility forever)

What the X-UA-Compatible flag does is tell newer versions of IE to fall back into compatibility mode to emulate older versions. So therefore, your content="IE-8" flag will have no effect on IE7 or IE8, but will make IE9 fall back into IE8 mode.

This means that IE9 will effectively throw away its newer features, in the name of trying to be backward compatible.

If this is what you want from IE9, then by all means use the X-UA-Compatible header. If it isn't what you want, then don't use it.

(it's worth noting that the backward compatibility modes in IE are known to be not very good at being 100% compatible with real copies of the version they're trying to emulate, so don't think that you'll get a perfect copy of IE8 running in IE9 either -- it'll have it's own quirks that are different to either IE8 or IE9 in normal mode)

Another thing to be aware of is that the tag examples microsoft have provided don't always work. read defining document compatibility , especially the community additions at the bottom of the page.

As far as best practice goes, they are probably not the best long term solution but came in very handy when IE9 was released and sites went down.

每个人都正确地说的向后兼容性应该仅在严格要求时应用,因为它不能完美地工作,并且不能通过添加兼容性标签来获得新浏览器的功能到旧浏览器。

I have IE8 installed in a Windows 7 test environment and it renders some parts of my code like IE7 did before (an there is no content="IE7" in my meta-tags)!
On another machine with Windows 7 + IE8, the code is rendered different, but the way I want.
There's an interesting article at http://www.greywyvern.com/?post=313 telling that the way IE8 renders depends of the Service Pack installed on the system (the article is about XP, but mine is Windows 7 and I have the same issue).

So now I put content="IE10" on my webpages and my website is correctly displayed in IE10, IE9 and IE8.

I'm using Discus, it is not compatible with older versions of IE. I got help they said to use content="IE-8" in my page code...

content="IE-8" also told my browser to change the sizes of tables and texts etc :p I changed to content="IE-7" it works perfect.

Adding <meta http-equiv=“X-UA-Compatible” content=“IE=8” /> mode in not probably good idea since it will stop your application to take advantages of newer versions of browser. But I think adding <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> is good since It forces the browser the render at whatever the most recent version's standards are.

Note: Adding Edge can potentially break your code since your application might not be tested for this new version. In most cases, this works absolutely fine, but you never know.

For details about other possible options refer

“X-UA-Compatible” content=“IE=9; IE=8; IE=7; IE=EDGE”

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