Jquery判断ie浏览器版本,用$.support替换$.browser判断

发布于:
Script

如果你也是Jquery最初的使用者,那么你一定经历过这样判断浏览器的时代:$.browser.msie && $.browser.version,你目前使用的组件里可能还有应用。但是Jquery1.3以后就不建议使用了,到jQuery 1.9之后就不复存在了。应该是因为到ie8以上的版本判断就有问题了…

只有另外想办法,使用$.support来判断浏览器!测试如下代码:

alert($.support.opacity+" "+$.support.style+" "+window.XMLHttpRequest);

ie6:false false undefind

ie7:false false object

ie8:false true object

ie9:true true object

SO,判断浏览器可以:alert($.support.opacity+" "+$.support.style+" "+window.XMLHttpRequest);

var isIE6 = !$.support.opacity && !$.support.style && window.XMLHttpRequest==undefined;

var isIE7 = !$.support.opacity && !$.support.style && window.window.XMLHttpRequest!=undefined;

var isIE67 = !$.support.opacity && !$.support.style;//ie67

如果要检查ie浏览器,干脆直接使用 var isIE = /msie/.test(navigator.userAgent.toLowerCase());

条件注释判断兼容浏览器版本CSS HACK

发布于:
Script
<!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]-->
<!--[if IE]> 所有的IE可识别 <![endif]-->
<!--[if IE 6]> 仅IE6可识别 <![endif]-->
<!--[if lt IE 6]> IE6以及IE6以下版本可识别 <![endif]-->
<!--[if gte IE 6]> IE6以及IE6以上版本可识别 <![endif]-->
<!--[if IE 7]> 仅IE7可识别 <![endif]-->
<!--[if lt IE 7]> IE7以及IE7以下版本可识别 <![endif]-->
<!--[if gte IE 7]> IE7以及IE7以上版本可识别 <![endif]-->
<!--[if IE 8]> 仅IE8可识别 <![endif]-->
<!--[if IE 9]> 仅IE9可识别 <![endif]-->

<!–[if lt IE 9]>
加载CSS1
<!–[else]>
加载CSS2
<![endif]–>