How do I detect what browser is used to access my site?

前端 未结 11 2174
盖世英雄少女心
盖世英雄少女心 2021-01-13 13:51

How do I detect what browser (IE, Firefox, Opera) the user is accessing my site with? Examples in Javascript, PHP, ASP, Python, JSP, and any others you can think of would b

11条回答
  •  醉酒成梦
    2021-01-13 14:11

    You can use the HttpBrowserCapabilities Class in ASP.NET. Here is a sample from this link

    private void Button1_Click(object sender, System.EventArgs e)
    {
            HttpBrowserCapabilities bc;
            string s;
            bc = Request.Browser;
            s= "Browser Capabilities" + "\n";
            s += "Type = " + bc.Type + "\n";
            s += "Name = " + bc.Browser + "\n";
            s += "Version = " + bc.Version + "\n";
            s += "Major Version = " + bc.MajorVersion + "\n";
            s += "Minor Version = " + bc.MinorVersion + "\n";
            s += "Platform = " + bc.Platform + "\n";
            s += "Is Beta = " + bc.Beta + "\n";
            s += "Is Crawler = " + bc.Crawler + "\n";
            s += "Is AOL = " + bc.AOL + "\n";
            s += "Is Win16 = " + bc.Win16 + "\n";
            s += "Is Win32 = " + bc.Win32 + "\n";
            s += "Supports Frames = " + bc.Frames + "\n";
            s += "Supports Tables = " + bc.Tables + "\n";
            s += "Supports Cookies = " + bc.Cookies + "\n";
            s += "Supports VB Script = " + bc.VBScript + "\n";
            s += "Supports JavaScript = " + bc.JavaScript + "\n";
            s += "Supports Java Applets = " + bc.JavaApplets + "\n";
            s += "Supports ActiveX Controls = " + bc.ActiveXControls + "\n";
            TextBox1.Text = s;
    }
    

提交回复
热议问题