Opened 10 years ago

Closed 10 years ago

#10021 closed defect (fixed)

sniff: dj_ie8 not set properly for docs w/meta tag specifying compatibility mode

Reported by: bill Owned by: James Burke
Priority: high Milestone: 1.4
Component: Core Version: 1.3.2
Keywords: Cc:
Blocked By: Blocking:

Description

From Michael Schall's email:

We’re trying to make sense of the various IE8 compatibility mode settings and have ran into a problem with the dijit sniffer.

To determine if the document mode is IE8 standards, you cannot rely on the User Agent string. In IE8, there is a property documentMode property on the document object that returns 5 for Quirks Mode, 7 for IE7 standards mode, and 8 for IE8 standards mode. See http://msdn.microsoft.com/en-us/library/cc196988(VS.85).aspx

When IE8 is in the IE8 Compatibility View browser mode, the document mode can be any of these values, but the User Agent claims that you’re actually using IE7. When sniffing the browser version and deciding which class to apply to the html element, the following happens:

dj_ie7: maj(ie) == 7,
dj_ie8: maj(ie) == 8,

This is not always correct, as the User Agent could be 7 but the document mode could be 8. I propose that this should be fixed by using the document mode (if available) to determine which class to apply:

dj_ie7: maj(ie) == 7 && (typeof(d.doc.documentMode) ==
             'undefined' || d.doc.documentMode == 7),
dj_ie8: d.doc.documentMode == 8,

Change History (4)

comment:1 Changed 10 years ago by James Burke

A side note, dojo.isIE uses documentMode in its setting, not sure if that applies here though.

comment:2 Changed 10 years ago by bill

Component: DijitCore
Owner: changed from bill to James Burke

The reason sniff.js is failing is that dojo.isIE == 7. This code in hostenv_browser.html *is* running:

if(document.all && !d.isOpera){
    d.isIE = parseFloat(dav.split("MSIE ")[1]) || undefined;
    //In cases where the page has an HTTP header or META tag with
    //X-UA-Compatible, then it is in emulation mode, for a previous
    //version. Make sure isIE reflects the desired version.
     //document.documentMode of 5 means quirks mode.
    if(d.isIE >= 8 && document.documentMode != 5){
         d.isIE = document.documentMode;
     }
}

However, the first line sets dojo.isIE to 8 so the nested if() never runs. In other words, dojo handles the case of

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

but not:

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

This isn't a regression so I guess we want to mark it for 1.5?

comment:3 Changed 10 years ago by bill

PS: from Mike's email:

The problem comes in that if you are in IE8 running in IE8 compatibility view, but have told it to use standards mode using the meta tag. It seems to be some kind of hybrid.

Like you are using IE7's javascript engine, but IE8's css engine.

Hit the following url in IE8 http://www.schallcentral.com/ie-ua-test.htm

You should see a div (green background) with text (hello world) in it within a div (red background).

By default, the green div will not be centered. This is IE8 Standard css engine. If you open the dev tools and click refresh on the html tab, you will see the html node has class="dj_ie dj_contentbox" and browser mode: IE8 and document mode: IE8 Standard.

Back in IE8, select Tools->Compatibility View Settings and add schallcentral.com to the list. Close and reopen IE and browse back to my test page.

The green div will still not be centered. This is IE8 Standard css engine. If you open the dev tools and click refresh on the html tab, you will see the html node has class="dj_ie dj_ie7 dj_contentbox" and browser mode: IE8 Compat View and document mode: IE8 Standard.

If you change to Document Mode to IE7 Stnadards, the green div will be centered.

I believe this is due to the client saying they want to view in compat mode, but I have added the meta tag to force IE8 <meta http-equiv="X-UA-Compatible" content="IE=8"/>

So you can have the user agent tell you it is IE7, but have an IE8 rendering engine. My problem is that intranet sites are by default included in the IE8 compat list.

comment:4 Changed 10 years ago by James Burke

Resolution: fixed
Status: newclosed

(In [20575]) Fixes #10021, use more generic tests for documentMode, but seems like a very weird test scenario.

Note: See TracTickets for help on using tickets.