"document.all?" == IE ?
发现 document.all? 判断实际上不能判断是不是 IE,ff 是不支持 document.all,但是 Opera 支持 document.all。
alert(document.all);
在 Opera 里面会得到 [object HTMLCollection] 。而且 Opera 可以标识为 IE(默认) ,甚至能在 navigator.userAgent 里面搜到 msie 。按下 f12 看看,它能伪装为很多东西。
简单写了一个判断浏览器的代码,在几个浏览器里面测试还没发现 bug:
<script>window.env=new function(){
this.isOpera=(window.opera&&navigator.userAgent.match(/opera/gi))?true:false;
this.isIE=(!this.isOpera&&document.all&&navigator.userAgent.match(/msie/gi))?true:false;
this.isSafari=(!this.isIE&&navigator.userAgent.match(/safari/gi))?true:false;
this.isGecko=(!this.isIE&&navigator.userAgent.match(/gecko/gi))?true:false;
this.isFirefox=(!this.isIE&&navigator.userAgent.match(/firefox/gi))?true:false;
};
//=====================
var s = "";
for (var i in env) {
s += i + " : " + env[i] + "\n";
}
alert(s);
</script>
http://www.mmommo.com/?id=65
from:asp学习网/title:"document.all?" == IE ?/ time:2007-2-24 21:09:45本文主题"document.all?" == IE ?