Browser detection

前端 未结 6 1460
春和景丽
春和景丽 2020-11-30 00:35

I need to separate IE and FF browsers from others

it\'s a pseudo-code :

If (CurrentBrowser == IE(6+) or FF(2+) )
{
...
}
else 
{
...
}
6条回答
  •  感情败类
    2020-11-30 00:47

    Here's a way you can request info about the browser being used, you can use this to do your if statement

    System.Web.HttpBrowserCapabilities browser = Request.Browser;
        string s = "Browser Capabilities\n"
            + "Type = "                    + browser.Type + "\n"
            + "Name = "                    + browser.Browser + "\n"
            + "Version = "                 + browser.Version + "\n"
            + "Major Version = "           + browser.MajorVersion + "\n"
            + "Minor Version = "           + browser.MinorVersion + "\n"
            + "Platform = "                + browser.Platform + "\n"
            + "Is Beta = "                 + browser.Beta + "\n"
            + "Is Crawler = "              + browser.Crawler + "\n"
            + "Is AOL = "                  + browser.AOL + "\n"
            + "Is Win16 = "                + browser.Win16 + "\n"
            + "Is Win32 = "                + browser.Win32 + "\n"
            + "Supports Frames = "         + browser.Frames + "\n"
            + "Supports Tables = "         + browser.Tables + "\n"
            + "Supports Cookies = "        + browser.Cookies + "\n"
            + "Supports VBScript = "       + browser.VBScript + "\n"
            + "Supports JavaScript = "     + 
                browser.EcmaScriptVersion.ToString() + "\n"
            + "Supports Java Applets = "   + browser.JavaApplets + "\n"
            + "Supports ActiveX Controls = " + browser.ActiveXControls 
                  + "\n";
    

    MSDN Article

提交回复
热议问题