asp使用ServerVariables集合(2)

时间:2008-02-27 13:22:00 

检测浏览器的版本

ServerVariables集合中,另外一个有用的值是用户浏览器的用户代理字符串。在“Detecting the Browser Type”页面(browsertype.asp),使用ServerVariables集合中的“HTTP_USER_AGENT”值来获得用户代理字符串,一些脚本用来解析该信息并寻找生产厂家名称和浏览器版本。 
    

<% 
     strUA = Request.ServerVariables(“HTTP_USER_AGENT”) 
     Response.Write “The User Agent string is <B>” & strUA & “</B> 
     ” 
     If InStr(strUA, “MSIE”) Then 
     Response.Write “To upgrade your browser go to “_ 
     & “<A HREF=” & Chr(34) & http://www.microsoft.com/ie/”_ 
     & Chr(34) & “>http://www.microsoft.com/ie/<A> 
     ” 
     intVersion = Cint(Mid(strUA, InStr(strUA, “MSIE”) + 5, 1)) 
     If intVersion >=4 Then 
     Response.Write “You can use Microsoft Dynamic HTML” 
     End If 
     Else 
     If InStr(strUA, “Mozilla”) Then 
     If InStr(strUA, “compatible;”) = 0 Then 
     Response.Write “Your browser is probably Navigator. You can “_ 
     & “download the latest version of Navigator from “_ 
     & “<A HREF=” & Chr(34) & http://home.netscape.com/”_ 
     & “download/”& Chr(34) & “>http://home.netscape.com”_ 
     & “/download/</A> 
     ” 
     intVersion = Cint(Mid(strUA, InStr(strUA, “/”) +1, 1)) 
     If intVersion >= 4 Then 
     Response.Write “You can probably use Netscape Dynamic HTML” 
     End If 
     Else 
     strVersion = Mid(strUA, InStr(strUA, “compatible;”) + 12) 
     strProduct = Left(strVersion, InStr(strVersion, “ “)) 
     Response.Write “Your browser is Navigator-compatible. You can”_ 
     & “search for the manufacturer using a search engine, such as”_ 
     & “<A HREF=” & Chr(34) _ 
     & “http://www.altavista.digital.com/cgi-bin/query?q=”_ 
     & strProduct _ 
     & Chr(34) & “>http://www.altavista.com/</A> 
     ” 
     End If 
     End If 
     End If 
     %> 

IE 5.0和Navigator 4.61的搜索结果分别不同,对于其他厂家的浏览器,可以得到一个链接在Alta Vista Web站点自动开始搜索厂家的名称。



     注意,Netscape在用户代理字符串中不提供厂家的名称,因而无法绝对保证一个浏览器一定是Navigator。

标签:ServerVariables,对象,集合,asp
0
投稿

猜你喜欢

  • 对于Python中线程问题的简单讲解

    2023-12-28 10:16:31
  • python异步任务队列示例

    2021-05-04 03:09:07
  • Vue.js 使用v-cloak后仍显示变量的解决方法

    2024-06-07 15:20:56
  • js和php如何获取当前url的内容

    2023-11-14 10:09:12
  • vue圆环百分比进度条组件功能的实现

    2024-06-07 15:19:57
  • 如何增大MYSQL数据库连接数

    2010-10-25 20:28:00
  • CSS教程:简单理解em

    2008-07-03 12:44:00
  • ts封装axios最佳实践示例详解

    2024-04-19 09:59:07
  • python原类、类的创建过程与方法详解

    2023-01-26 06:59:27
  • Python中的面向对象编程详解(上)

    2021-10-12 14:33:45
  • Python win32com 操作Exce的l简单方法(必看)

    2022-12-04 10:20:36
  • 查看python安装路径及pip安装的包列表及路径

    2021-10-25 01:36:48
  • Python 文件数据读写的具体实现

    2023-07-08 12:15:06
  • 小诀窍让你快速上手Dreamweaver

    2007-12-03 11:35:00
  • python爬虫爬取笔趣网小说网站过程图解

    2022-10-06 10:56:50
  • mysql5.6.8源码安装过程

    2024-01-22 02:53:41
  • laravel的用户修改密码与绑定邮箱的详细操作

    2023-06-17 09:55:06
  • Python3单行定义多个变量或赋值方法

    2022-03-22 17:10:53
  • Go语言题解LeetCode268丢失的数字示例详解

    2024-05-02 16:24:29
  • Python实现上下文管理器的方法

    2021-06-22 17:31:15
  • asp之家 网络编程 m.aspxhome.com