For at least IE8 and IE9, you can check whether navigator.userAgent
has the substring Trident
in it. An IE8+ always has a Trident
in its user-agent, where an IE7 doesn’t. See this answer and the MSDN link in it.
IE10 seems trickier: it is reported in the comments below that Trident
is not always present with IE7 emulation mode. Probably the OS string (eg. Windows NT 6.2
) will still reveal IE10, if IE10 will not be available on any platform where IE7 is available.
Please also note that the HTTP User-Agent
header might not always match navigator.userAgent
. This is the case at least with IE9 that has compatiblity mode on (sends an IE7 User-Agent
header) but detects something like IE=Edge
in the response (navigator.userAgent
turns back to IE9).