本Javascript函数放到网页中,网页打开时会自动运行
<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>
<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>