用 JavaScript来判断浏览器的种类

首先新建一个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目录下,运行一下试试看。

原文地址:https://www.cnblogs.com/MicroGoogle/p/1704905.html