In some existing code there is a test to see if the user is running IE, by checking if the object Browser.Engine.trident is defined and returns true.
But how can I determine if the user is running IE6 (or earlier) or IE7 (or later)?
The test is needed inside a JavaScript function so a conditional comment doesn't seem suitable.
If you are checking for a certain functionality, you should check for it directly, e.g.
if (window.focus) {window.focus();}
Browser detection is never reliable enough.For more details on object vs browser detection, check out this article at Quirksmode.
On the other hand, if the feature you need IS the browser type and version, e.g. for statistical purposes, go with
navigator.appName
andnavigator.appVersion
. (Beware though - many less popular browsers masquerade themselves as MSIE 6 or 7, as certain sites block anything that's not IE on the premise that "all the modern browsers are IE, right?" (hint: not anymore).)Well... here is what I came up after thinking for a while. just wanted to find a simple solution.
It returns ex:- MSIE 10.0, MSIE 9.0, MSIE 8.0
further extend, if you want to check if it's "lower than" or "greater than" IE version, you can slightly modify
got the base idea from w3schools, hope this will help some one... :D
If you are already using jQuery in a pre-1.9 version AND you don't need to detect IE 11, you can do this:
From detecting Internet Explorer More Effectively at msdn:
This should give you more details than you'll want: