日期:2014-05-17 浏览次数:20765 次
<SCRIPT LANGUAGE="JavaScript">
<!--
alert(window.navigator.userAgent);
if (window.navigator.userAgent.indexOf("MSIE")>=1)
{
alert("ie");
}else{
if (window.navigator.userAgent.indexOf("Firefox")>=1)
{
alert("firefox");
}else if (window.navigator.userAgent.indexOf("Chrome")>=1){
alert("chome");
} else{alert("others");}
}
</SCRIPT>
区别IE6与FF:
background:orange;*background:blue;
区别IE6与IE7:
background:green !important;background:blue;
区别IE7与FF:
background:orange; *background:green;
区别FF,IE7,IE6:
background:orange;*background:green !important;*background:blue;
注:IE都能识别*;标准浏览器(如FF)不能识别*;
IE6能识别*,但不能识别 !important,
IE7能识别*,也能识别!important;
FF不能识别*,但能识别!important;
p.test {
background-color: red;
*background-color: blue;//IE6
background-color: blue!important;//IE7..比下面的级别低。共存时使用下面css
}
*:first-child+html p.test {
background-color: black;//IE7下
}
</style>
</head>
<body>
<body>
<p class="test">333333333333333333333</p>
</body>
IE7可以辨识「*」和「!important」,//已验证 但是IE6只可以辨识「*」,却无法辨识「!important」,//验证失败、、ie仍然可以识别 至于Firefox可以读取「!important」但不能辨识「*」//已验证 因此可以透过这样的差异来有效区隔IE6、IE7、Firefox。