检测浏览器类型 [英] Detecting a browser type

查看:271
本文介绍了检测浏览器类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Togeather错误在我的asp.net应用报告,我也retreiving浏览器的信息。比如我得到特定的错误很多:

 键入= Mozilla的
名称= Mozilla的
版本= 5.0
主版本= 5
次版本= 0
平台=未知
是测试版=假
是履带=假
是AOL = FALSE
是的Win16 = FALSE
是Win32 = FALSE
支持框架=假
支持表=假
支持Cookie =假
支持使用VBScript = FALSE
支持JavaScript = FALSE
0.0
支持Java小程序=假
支持ActiveX控件=假

我的第一个想法是Firefox,但我ASLO在某些误差修改获取Firefox,所以我不知道什么是从上面的信息的确切浏览器?

感谢


解决方案

 尝试以下的Response.Write(Request.ServerVariables(HTTP_USER_AGENT))

//获取访问者的浏览器名称

 如果(Request.ServerVariables [HTTP_USER_AGENT]。载有(MSIE))
  浏览器=Internet Explorer的;
如果(Request.ServerVariables [HTTP_USER_AGENT]。载有(火狐))
  浏览器=火狐狸
如果(Request.ServerVariables [HTTP_USER_AGENT]。载有(歌剧))
  浏览器=戏;

Togeather with error reporting in my asp.net app, I am also retreiving browser information. For example I am getting specific error a lot:

Type = Mozilla
Name = Mozilla
Version = 5.0
Major Version = 5
Minor Version = 0
Platform = Unknown
Is Beta = False
Is Crawler = False
Is AOL = False
Is Win16 = False
Is Win32 = False
Supports Frames = False
Supports Tables = False
Supports Cookies = False
Supports VBScript = False
Supports JavaScript = False
0.0
Supports Java Applets = False
Supports ActiveX Controls = False

My first idea was firefox, but I aslo get firefox in certain erros, so I am not sure what is the exact browser from the information above?

Thanks

解决方案

TRY BELOW

Response.Write(Request.ServerVariables("HTTP_USER_AGENT")) 

// Getting Browser Name of Visitor

if (Request.ServerVariables["HTTP_USER_AGENT"].Contains("MSIE"))
  browser = "Internet Explorer";
if (Request.ServerVariables["HTTP_USER_AGENT"].Contains("FireFox"))
  browser = "Fire Fox";
if (Request.ServerVariables["HTTP_USER_AGENT"].Contains("Opera"))
  browser = "Opera";

这篇关于检测浏览器类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆