How can I detect IE 7 and IE 8 using jQuery.support properties?
Is it possible to detect the browser versions using jQuery.support or just those blah blah blah brows
if (jQuery.support.leadingWhitespace == false){
... code for IE7-IE8 ...
}
else {
...
}
Use jQuery.browser.version instead of support
One trick I found is to add Conditionnal Tags in the HTML
<!--[if lt IE 7]><body class="ie ie6 lte9 lte8 lte7"><![endif]-->
<!--[if IE 7]><body class="ie ie7 lte9 lte8 lte7"><![endif]-->
<!--[if IE 8]><body class="ie ie8 lte9 lte8"><![endif]-->
<!--[if IE 9]><body class="ie ie9 lte9"><![endif]-->
<!--[if !IE]><!--><body class="not-ie"><!--<![endif]-->
Then use JQuery like this :
$('body.ie7')
It also helps for CSS on IE specific
body.ie6{ margin: 0; }
I don't know if it's good for you but anyways, that's still an option.
Be careful with the following because it also includes IE10:
if ($.browser.msie && $.browser.version.substr(0,1)<7) {
//<IE7
}
better use:
if ($.browser.msie && parseInt($.browser.version,10)<7) {
//<IE7
}
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
var ieversion = new Number(RegExp.$1);
alert(ieversion < 9);
}
Try $.browser, it will let you know if browser version is less than IE9
var isM = false;
$.each($.browser, function (i, val) {
if ($.browser.msie && parseInt(val) < 9) isM = true;
});