How can I detect if my app runs under IE8 vs IE9 in JavaScript?

164 views Asked by At

I have a piece of functionality which needs to differ between IE8 and IE9 (IE9 uses a very nice library that is the main code path, but a slight minority of users of the app are still on IE8 which the library breaks under. So I need to gracefully degrade to less-nice library for them).

What is the best way to distinguish IE8 from IE9?

If possible, I'd like a version of the answer which treats IE9 with IE8 compatibility turned on as IE8; and one that treats it as IE9.

There's zero need to detect any other browsers or IE versions - this is for a locked down corporate environment so there's no risk of needing to detect beyond those 2.

1

There are 1 answers

0
user1659653 On

Conditional Comments. There are some other alternatives but conditional comments are simple and functional. MSFT provides this information http://msdn.microsoft.com/en-us/library/ms537509(v=vs.85).aspx