Alex Rivera | Logout

Detect Internet Explorer 6 or below in jQuery

Asked 2009-02-19T17:24:53.537
45

I'm new to jquery and was wondering: is a simple way to detect whether a browser is Internet Explorer 6 or below?

Edit
Report

2 Answers

5

If ActiveXObject exists and XMLHttpRequest does not, it's IE6:

/* IE6 Check */
(!!window.ActiveXObject && !window.XMLHttpRequest) ? true : false;

In IE7, it would be:

(!!window.ActiveXObject && !!window.XMLHttpRequest) ? true: false;

References

answered 2012-01-09T22:25:36.423
1

Just to let people know $.browser.msie && /6.0/.test(navigator.userAgent) is not reliable, I've come to this question looking for an answer to a problem with the JQuery bgiframe which breaks on my machine because I have 'Media Center PC 6.0' in my navigator.userAgent string. I've now edited the source to use the $browser.version test.

Its silly of JQuery to deprecate these browser tests because ugly as they may be they are necessary to deal with the ugly state of the browser ecosystem.

answered 2010-12-10T11:38:21.627

Your Answer