如何判断是什么样的浏览器 不让非IE的浏览器登录?有没有现成的代码啊?

解决方案 »

  1.   

    if(navigator.userAgent.toString().indexOf('MSIE')== -1)
        {
           非IE。
    navigator.userAgent.split(" ")[3].split(".")[0]; IE版本
        }
      

  2.   

    var Browser = {
        IE:     !!(window.attachEvent && !window.opera),
        Opera:  !!window.opera,
        WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
        Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1,
        MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
    }
    alert(Browser.IE);
      

  3.   

    <script type="text/javascript">
            var Sys = {};
            var ua = navigator.userAgent.toLowerCase();
            if (window.ActiveXObject)
                Sys.ie = ua.match(/msie ([\d.]+)/)[1]
            else if (document.getBoxObjectFor)
                Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1]
            else if (window.MessageEvent && !document.getBoxObjectFor)
                Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1]
            else if (window.opera)
                Sys.opera = ua.match(/opera.([\d.]+)/)[1]
            else if (window.openDatabase)
                Sys.safari = ua.match(/version\/([\d.]+)/)[1];
           
            //以下进行测试
            if(Sys.ie) document.write('IE: '+Sys.ie);
            if(Sys.firefox) document.write('Firefox: '+Sys.firefox);
            if(Sys.chrome) document.write('Chrome: '+Sys.chrome);
            if(Sys.opera) document.write('Opera: '+Sys.opera);
            if(Sys.safari) document.write('Safari: '+Sys.safari);    </script>
      

  4.   

    IE:!!(window.attachEvent&&!window.opera)不支持Firefox/3.0.1,3.0.1已经支持window.attachEvent方法了。
      

  5.   

    Request.Header[”User-Agent”] 得到浏览器的 User Agent,也可以使用 Request.UserAgent 来获取
      

  6.   

    如何写在aspx里啊  直接写吗?
      

  7.   

    <html><SCRIPT LANGUAGE="JavaScript">
    <!--
    if (window.navigator.userAgent.indexOf("MSIE")>=1)
    {
    //浏览器为IE
    alert("IE");
    }else{
    if (window.navigator.userAgent.indexOf("Firefox")>=1)
    {
    //浏览器为Firefox
    alert("Firefox");
    }else{
    //浏览器为其他
    alert("什么浏览器?");
    }
    }
    //-->
    </SCRIPT>
    </html>