Email conversation
From | Alexei White |
To | Me |
Subject | Detecting IE8 in IE7 compatibility mode |
Date | 26 March 2008 17:14 |
Hey I was reading your article on IE8 changes and was curious about
your mention that the IE7 compatibility mode still exposes some IE8
script properties. I would like to leverage this to detect IE8 when
operating in IE7 mode.. can you give me any examples of script
differences I might use to do this?
Thanks!
Alexei
From | Me |
To | Alexei White |
Subject | Re: Detecting IE8 in IE7 compatibility mode |
Date | 29 March 2008 08:44 |
Alexei,
> I would like to leverage this to detect IE8 when operating in IE7 mode.
The document.documentMode property gives the version mode it is
operating in (currently 5, 7 or 8). This is a floating point number and
will increase for new versions, perhaps 8.5 or 9 or 10.35 etc. It is a
new property in IE 8, so you can use it to see if it is IE 8+ in IE 7
mode, but it will not be possible to use its existence to check for IE 9
operating in IE 8 mode. It would be more useful if there were some
property like document.maximumMode so you could see if it is really
version 9 in version 8 mode, but I guess we will have to wait and see
what new stuff appears in IE 9.
Note that this property is non-standard, so it will not exist at all in
other browsers, and it is very important that you do not display silly
messages in other browsers because it does now exist and is therefore
smaller than 8.
For now, the only use I can see for this is:
if( document.documentMode && document.documentMode < 8 ) {
document.write('Please allow this site to render in standards mode.');
}
Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
From | Alexei White |
To | Me |
Subject | Re: Detecting IE8 in IE7 compatibility mode |
Date | 29 March 2008 17:00 |
Thanks for responding. I figured it would be something like that. I
guess we'll need to see what changes in IE9 to detect that. I also
presume that people will stop 'emulating' IE7 once IE8 RC is available
and the CSS model settles down.
In the meantime I found another, similar way to detect IE8 in IE7
mode: [Checking for the XDomainRequest object and IE 7 UA string]
Crude, but seems to work :)
Thanks again,
Alexei