ASP中利用navigator.appVersion识别Windows Vista操作系统的代码实现

作者:清欢

时间:2026-10-22

浏览:131

本文详细解析在ASP环境中如何通过VBScript脚本利用navigator.appVersion属性准确识别Windows Vista操作系统。文章提供了完整的函数代码,涵盖从Windows 95到NT 4.0及Vista系统的判断逻辑,并指出原代码中针对Vista判断缺失的问题,旨在帮助开发者完善旧版Web应用的系统兼容性检测功能。

文章目录

ASP识别Windows Vista系统的需求背景

如何在ASP环境中准确识别当前访问者是否使用Windows Vista操作系统?许多开发者在网上搜索相关函数,但发现现有代码往往无法正确判断Vista系统,因此需要更完善的解决方案。


现有Vista识别代码分析

以下是一个从网络获取的参考函数,但该函数存在缺陷,无法正确识别Vista系统。


Function GetCurrOS()


Dim Info


Info = navigator.appVersion


If Instr(info,"NT 5.1")>0 Then


GetCurrOS = "Windows XP"


ElseIf Instr(info,"Tel")>0 Then


GetCurrOS = "Telport"


ElseIf Instr(info,"webzip")>0 Then


GetCurrOS = "webzip"


ElseIf Instr(info,"flashget")>0 Then


GetCurrOS = "flashget"


ElseIf Instr(info,"offline")>0 Then


GetCurrOS = "offline"


ElseIf Instr(info,"NT 5")>0 Then


GetCurrOS = "Windows 2000"


ElseIf Instr(info,"NT 4")>0 Then


GetCurrOS = "Windows NT4"


ElseIf Instr(info,"98")>0 Then


GetCurrOS = "Windows 98"


ElseIf Instr(info,"95")>0 Then


GetCurrOS = "Windows 95"


Else


GetCurrOS = "UnKnow"


End If


End Function


如果您有更完善的函数代码,欢迎分享,在此先表示感谢。


代码运行与测试环境

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Codetrinis Test</title> </head> <body>  </body> </html>

[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]

实用工具推荐

电子包浆

绿化、压缩、噪点和虚拟水印,自由调节做旧程度。

使用 ›
图片压缩

选择画质和输出格式,预览压缩前后的大小。

使用 ›
相关文章