Using JavaScript to detect IE 8

I was just thinking to use the following JavaScript to detect IE 8:

  navigator.appVersion.indexOf("MSIE 8") > -1

But you know, when IE 8 is in compatibility mode, the agent string will become MSIE 7 instead.

So, use the following to check for IE 8 for safe:

  navigator.appVersion.indexOf("Trident/4") > -1


Comments

Popular posts from this blog

Java encoding : UTF-8, Big5, x-MS950-HKSCS