用 JavaScript来判断浏览器的种类
2010-04-05 21:23 jinze 阅读(196) 评论(0) 编辑 收藏 举报
首先新建一个html页面,如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Hello,IIS</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript">
function fu() {
if (navigator.userAgent.indexOf("MSIE") > 0) {
alert("MSIE");
}
else if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) {
alert("FireFox");
}
}
</script>
</div>
</form>
<input type="button" value="TestBrows" onclick="fu()" />
</body>
</html>
然 后放在本地的IIS或者Apache目录下,运行一下试试看。
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Hello,IIS</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript">
function fu() {
if (navigator.userAgent.indexOf("MSIE") > 0) {
alert("MSIE");
}
else if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) {
alert("FireFox");
}
}
</script>
</div>
</form>
<input type="button" value="TestBrows" onclick="fu()" />
</body>
</html>
然 后放在本地的IIS或者Apache目录下,运行一下试试看。