用代码判断客户端使用的浏览器版本
Response.Write(Request.ServerVariables["HTTP_USER_AGENT"]);(貌似ASP上也可用这个)
或
Response.Write(Request.UserAgent);
我的是IE7输出:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SE 1.X; .NET CLR
2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; SE 1.X)
谷歌浏览器输出:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.0
(KHTML, like Gecko) Chrome/3.0.195.38 Safari/532.0
1 public static int getBrowser() 2 { 3 string BrowserInfo = HttpContext.Current.Request.UserAgent; 4 if (BrowserInfo.Contains("MSIE 7.0")) 5 {//IE7 6 return 1; 7 } 8 else if (BrowserInfo.Contains("MSIE 6.0")) 9 {//IE6 10 return 2; 11 } 12 else if (BrowserInfo.Contains("Firefox")) 13 {//IE6 14 return 3; 15 } 16 else if (BrowserInfo.Contains("Chrome")) 17 {//谷歌 18 return 4; 19 } 20 return 5; 21 }