浏览器hack详细介绍

发布于:
Script

IE系列浏览器的hack大略如下:

_nowamagic:1px;-----------ie6
*nowamagic:1px;-----------ie7
nowamagic:1px;----------ie89
nowamagic:1px9;--------ie9
:root nowamagic:1px;    ----ie9(实际情况可能ie9还是有问题,再用这种方式)

 

1.‘9’:

.test { color/***/: blue9 }
.header {width:300px;} /* 所有浏览器*/
.header {width/***/:330px\9;} /* 所有浏览器IE浏览器 */
.header {*width:310px;} /* IE7和IE6能识别,IE8和FF不能识别*/
.header {_width:290px;} /* IE6能识别,IE7、IE8和FF不能识别*/

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());