I\'m new to jquery and was wondering: is a simple way to detect whether a browser is Internet Explorer 6 or below?
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
i always used this solution
http://sinfinity.pl/blog/2012/02/12/detect-internet-explorer-and-browser-version-in-jquery/
You could also ask IE directly.
<!--[if lte IE 6]>
<script type="text/javascript">
var isRunningIE6OrBelow = true;
</script>
<![endif]-->
I often check the version of a browser. The .support method is great, but it doesn't really help when you need to hide selects when there's an overlay. There is no "supports selects are windowed controls". You just need to check the browser version, so I would say err towards the .support method where you can, and use the .browser where necessary.
Very nice way to detect IE is:
if ('v'=='\v') {
welcome to IE ))
}
Unfortunately it can't recognize its version but it's not always nessecary.
Try this out:
jQuery.each(jQuery.browser, function(i, val) {
$("<div>" + i + " : <span>" + val + "</span>")
.appendTo(document.body);
});
if you need more info refer to this:
http://docs.jquery.com/Utilities/jQuery.browser