浏览器怎么样区分:{
<script>
function method() {
//alert(window.navigator.userAgent);
//将浏览器的版本信息全部转化为小写
var c = window.navigator.userAgent.toLowerCase();
//alert(c);
if(c.indexOf("msie")>0) {
alert("您用的是微软的ie浏览器");
}else if(c.indexOf("firefox")>0) {
alert("您用的是火狐");
}else if(c.indexOf("chrome")>0) {
alert("您用的是谷歌浏览器");
}else{
alert("不知道");
}
}
</script>
</head>
<body>
<a href="javascript:void(0);" onclick="method()">测试navigator对象</a>
</body>
}
|