I just had a play and found the following works for me:
<meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" >
That is with a comma not a semi colon!
I haven't looked at the spec, but the format is similar to content="IE=7,chrome=1" that works for Chrome Frame. I also found that content="IE=7,9" works but I suspect that is not a correct format.
Edit:
Beware of a serious problem if your page is in a iframe. If you use the above in a framed page where the parent is in any mode less than IE9 strict, then IE9 will fall back to IE8 mode (ignoring the IE=7 request!). Any known workarounds welcome :) Might not be relevant to IE11.
The above seems to be a side effect of the by design feature, that iframes (and I presume frames) are either all in IE9 mode, or all are less than IE9 mode. One can never mix IE9 frames with < IE9 frames, see MS issues #599022 and #635648.
Edit 2:
Beware that IE11 only supports "IE=edge" (not IE=11), and that using IE=edge has significant effects upon IE functionality (including the user agent).
Edit 3:
- Fantastic flow chart explaining how IE works out what mode to use for IE9
IE=edge
is supported by IE8 through to IE11.
- The Meta tag takes precedence over the HTTP header (which can be used instead of the meta tag)
- Some more X-UA-Compatible info for IE10.
Edit 4:
X-UA-Compatible
was removed from the Microsoft Edge browser. Only Internet Explorer has the compatibility modes. Beware that if you are using the WebView within an App on Windows Phone 10, then you are still using IE11 (not Edge).
Also for a variety of reasons you cannot trust the user agent to tell you the correct compatibility level, instead use document.documentMode
from JavaScript.
Edit 5:
IE11 still needs X-UA-Compatible
set to IE=EDGE
for some corner cases e.g. a customer using IE11 from ActiveX (as WebView within a wrapper application) can drop IE11 back to IE7 mode if you don't set this.
Actually the user agent string is different for IE9 when being run in IE7 compatibility mode, so this would be one of the best ways to distinguish between different IE versions.
Introducing IE9’s User Agent String:
Similar to IE8, IE9’s Compatibility
View will map to IE7 Standards Mode,
and IE9’s UA string when in
Compatibility View will be:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0)
In Compatibility View, IE9 reports
itself as IE7 through the application
version number (Mozilla/4.0) and
version token (MSIE 7.0). This is done
for compatibility. An incremented
Trident token, from ‘Trident/4.0’ to
‘Trident/5.0’, allows websites to
distinguish between IE9 running in
Compat View and IE8 running in Compat
View.
(emphasis added by me). So the user agent string is the same as it reports itself being "Mozilla/4.0" and MSIE 7.0, but IE9 will always be Trident/5.0 - no matter whether it says MSIE 7.0, MSIE 8.0 or MSIE 9.0.
Actually you should check out this great compilation: Browser ID (User-Agent) Strings or even better useragentstrings.com
Best Answer
I know nothing about Raphaël, but I do know that IE9 reports its JScript Version incorrectly. No matter what version you have Browser Mode/Document Mode set to, @_jscript_version returns 9. If Raphaël decides whether to use VML or SVG based on @_jscript_version, it could cause trouble.