Detecting Internet Explorer 6 or lower in jQuery

I'm new to jquery and wondering: is this an easy way to determine if Internet Explorer 6 or lower is browser?

+44
jquery internet-explorer-6
Feb 19 '09 at 17:24
source share
13 answers

The easiest way is:

if($.browser.msie && $.browser.version=="6.0") alert("Im the annoying IE6"); 

Update

Please note that $. browser removed from jQuery 1.9

If you still need to use $ .browser in jQuery 1.9 (or other deprecated features), try jQuery-migrate ( https://github.com/jquery/jquery-migrate/ - http://code.jquery.com/jquery -migrate-1.2.1.js )

+101
Jul 01 '09 at 10:28
source share

You can also ask IE directly.

 <!--[if lte IE 6]> <script type="text/javascript"> var isRunningIE6OrBelow = true; </script> <![endif]--> 
+50
May 05 '09 at 9:37
source share

jQuery checks functions, not browsers. However, you can use the jQuery.support method to determine what the users browser is capable of.

Deprecated Methods (Do Not Use)

  • $. Browser
  • $. Browser.version
  • $. BoxModel

http://docs.jquery.com/Utilities/jQuery.support will give you a brief description of what features are supported by browsers. By accepting this data, you will develop a couple of conditional checks to determine if the browser you are using is your target browser or not.

+16
Feb 19 '09 at 17:27
source share
 if ($.browser.msie && parseInt($.browser.version, 10) <= 6) { alert("I'm not dead yet!"); } 

- update

Please do not use $. browser removed from jQuery 1.9

+8
Nov 29 '11 at 12:39
source share

A very good way to detect IE:

 if ('v'=='\v') { welcome to IE )) } 

Unfortunately, he cannot recognize his version, but this is not always inconvenient.

+6
May 05 '09 at 9:24 p.m.
source share

If ActiveXObject exists and XMLHttpRequest does not exist, this is IE6:

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

In IE7, this will be:

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

References

+5
Jan 09 '12 at 22:25
source share

Also, another good point is that with jQuery you don't have to worry about the version.

This will not help if you use jquery to fix IE6 css rendering error.

+3
Aug 05 '09 at 13:37
source share

I often check the browser version. The .support method is great, but it doesn’t really help when you need to hide the selection when there is an overlay. No "support lookups are window controls." You just need to check the browser version, so I would say that I am mistaken in the .support method, where possible, and use .browser if necessary.

+3
Jan 19 '10 at 11:53
source share

Just to let people know $ .browser.msie && & / 6.0 / .test (navigator.userAgent) is not reliable, I came up with this question looking for an answer to a problem with jguery bgiframe that breaks on my machine because I have Media Center PC 6.0 in my line navigator.userAgent. Now I edited the source to use the $ browser.version test.

Its stupid of jQuery to discount these browser tests because they are ugly, as they may be necessary to eliminate the ugly state of the browser ecosystem.

+1
Dec 10 2018-10-10
source share
+1
Feb 13 2018-12-12T00:
source share

http://docs.jquery.com/Utilities/jQuery.browser.version as

EDITED: Fixed link from Douglas

http://api.jquery.com/jQuery.browser/#jQuery.browser.version

I mean, if you had an old version of not the latest version 1.3 ...

Also, another good point is that with jQuery you don't have to worry about the version. JQuery really does the testing and processes all of these malaria for you. Concerned about versions and platforms pretty 1999

0
Feb 19 '09 at 17:28
source share

Try the following:

  jQuery.each(jQuery.browser, function(i, val) { $("<div>" + i + " : <span>" + val + "</span>") .appendTo(document.body); }); 

if you need more information, refer to this:

http://docs.jquery.com/Utilities/jQuery.browser

0
Feb 19 '09 at 17:29
source share

"While it is unlikely that jQuery.browser will be removed, all efforts to use jQuery.support and the corresponding function should be done."

So, I say, keep using it. They must be backward compatible with scripts that still use the sniffing method of the user agent.

0
Oct 19 '09 at 15:18
source share



All Articles