如何检查用户浏览器是否是IE?我这里有这段代码,但它不起作用。
if($.browser.msie && $.browser.version <= 9)
{
alert('You Are Using An Outdated Browser! Switch To Chrome Or FireFox.');
}
Try 这个解决方案 http://ajaxian.com/archives/attack-of-the-ie-conditional-comment作者:詹姆斯·帕多尔西:
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
// And to detect the version:
// ie === 6 // IE6
// ie> 7 // IE8, IE9 ...
// ie <9 // Anything less than IE9
// ----------------------------------------------------------
var ie = (function(){
var undef, v = 3, div = document.createElement('div');
while (
div.innerHTML = '<!--[if gt IE '+(++v)+']><i></i><![endif]-->',
div.getElementsByTagName('i')[0]
);
return v> 4 ? v : undef;
}());
评论中还有其他有趣的解决方案。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)