Detect Internet Explorer 6 or below in jQuery

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


Solution 1:

As simple as this:

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

Update

Please note that $.browser is removed from jQuery 1.9

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

Solution 2:

You could also ask IE directly.

<!--[if lte IE 6]>
<script type="text/javascript">
  var isRunningIE6OrBelow = true;
</script>
<![endif]-->