Search code examples
htmlinternet-explorerie-compatibility-mode

IE issue with compatibility modes


I was wondering when I put my browser in compatibility mode, how does it know what setting to use from the header tags found in the document. If we have logic for all versions back to EI7, will it use the furthest back? So in this case, it chooses 7 in comp mode, but if we only offered back to IE8, then it would choose IE8 for that instance? So the question is, why does IE 11 compatibility mode set it to IE7 standards according to my debugger in IE? If I remove the [if IE7] code snippet, will it then set it to IE8 standards in the browser? We just quit supporting IE7 so am why I am asking this.

[if IE 7 ]>    <html class="ie7"
[if IE 8 ]>    <html class="ie8" 
[if IE 9 ]>    <html class="ie9"

Solution

  • In addition, the way you view your pages also affects the document mode.

    • If you view a page on the Internet (or through a local web browser), the page opens in the Internet zone. In this case, the x-ua-compatible directive takes precedence; depending on the setting, the <DOCTYPE> may also have an impact.
    • If you open the page using the File menu, from File Explorer, or from a network path, the page opens in the Intranet zone. By default, this means your page opens in IE7 compatibility mode, though that can be changed through settings.
    • Apps hosting the webBrowser control default to IE7 unless you override that using a registry change. (Note, it's currently unclear whether this is supported in Windows 10).

    For best results:

    1. Use the HTML5 <DOCTYPE> directive.
    2. Use an x-ua-compatible meta with content set to IE=edge.
    3. View local pages through a local webbrowser.
    4. Code for HTML5, detect features, provide graceful fallback, and worry less about individual differences between individual browsers.

    Hope this helps...

    -- Lance