Override intranet compatibility mode IE8

后端 未结 19 2487
执念已碎
执念已碎 2020-11-22 10:04

By default IE8 forces intranet websites into compatibility mode. I tried changing the meta header to IE8, but it doesn\'t acknowledge the meta header and just uses the brows

19条回答
  •  面向向阳花
    2020-11-22 10:29

    There is a certain amount of confusion in the answers to this this question.

    The top answer is currently a server-side solution which sets a flag in the http header and some comments are indicating that a solution using a meta tag just doesn't work.

    I think this blog entry gives a nice overview of how to use compatibility meta information and in my experience works as described: http://blogs.msdn.com/b/cjacks/archive/2012/02/29/using-x-ua-compatible-to-create-durable-enterprise-web-applications.aspx

    The main points:

    • setting the information using a meta tag and in the header both works
    • The meta tag takes precedence over the header
    • The meta tag has to be the first tag, to make sure that the browser does not determine the rendering engine before based on heuristics

    One important point (and I think lots of confusion comes from this point) is that IE has two "classes" of modes:

    1. The document mode
    2. The browser mode

    The document mode determines the rendering engine (how is the web page rendered).

    The Browser Mode determines what User-Agent (UA) string IE sends to servers, what Document Mode IE defaults to, and how IE evaluates Conditional Comments.

    More on the information on document mode vs. browser mode can be found in this article: http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx?Redirected=true

    In my experience the compatibility meta data will only influence the document mode. So if you are relying on browser detection this won't help you. But if you are using feature detection this should be the way to go.

    So I would recommend using the meta tag (in the html page) using this syntax:

    
    

    Notice: give a list of browser modes you have tested for.

    The blog post also advices against the use of EmulateIEX. Here a quote:

    That being said, one thing I do find strange is when an application requests EmulateIE7, or EmulateIE8. These emulate modes are themselves decisions. So, instead of being specific about what you want, you’re asking for one of two things and then determining which of those two things by looking elsewhere in the code for a DOCTYPE (and then attempting to understand whether that DOCTYPE will give you standards or quirks depending on its contents – another sometimes confusing task). Rather than do that, I think it makes significantly more sense to directly specify what you want, rather than giving a response that is itself a question. If you want IE7 standards, then use IE=7, rather than IE=EmulateIE7. (Note that this doesn’t mean you shouldn’t use a DOCTYPE – you should.)

提交回复
热议问题