建议使用 IE 进行测试,因为对 IE 以外的浏览器无法识别(经测试,IE 5 也是辨认不出来滴,不过我相信没有哪个火星人还在用 IE5 吧?)
<title>无标题文档</title>
<script language="javascript">
function c(){
var ie = (function(){
var undef,
v = 3,
div = document.createElement('div'),
all = div.getElementsByTagName('i');
while (
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
all[0]
);
return v > 4 ? v : undef;
}());
alert(ie);
}
</script>
</head>
<body οnlοad="c()">
</body>
</html>