C#获得浏览器类型源代码

///
/// 获得浏览器类型字符 贾世义
///

///
/// FF(Firfox) SF(Safari) OE(Opera) IE
public static string GetBrowser(HttpBrowserCapabilities browser)
{
if (browser == null)
{
return "IE";
}
else if (browser.Browser.IndexOf("IE", StringComparison.CurrentCultureIgnoreCase) != -1)
{
return "IE";
}
if (browser.Browser.IndexOf("Firefox", StringComparison.CurrentCultureIgnoreCase) != -1)
{
return "FF";
}
else if (browser.Browser.IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1)
{
return "SF";
}
else if (browser.Browser.IndexOf("Opera", StringComparison.CurrentCultureIgnoreCase) != -1)
{
return "OE";
}
else
{
return "IE";
}
}

你可能感兴趣的:(C#获得浏览器类型源代码)