当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 用js判断用户浏览器是否是XP SP2的IE6

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 用js判断用户浏览器是否是XP SP2的IE6


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 205 ::
收藏到网摘: n/a

由于Windows XP的补丁SP2,对IE6的安全性也做了很多的提升,使得有不少原来我们可以使用的功能,会变得很奇怪甚至歇菜掉:(。特别是弹出窗口、模态窗口和Popup窗口等受的影响相当大。那么我能不能判断用户使用的IE6是普通IE6(IE6sp1)还是IE6+xp sp2呢?
下面是两个比较典型的IE6浏览器UserAgent字段:
1、Windows XP + SP1 (NT 5.1)
Connection: Keep-Alive
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: zh-cn
Host: zhilee.aehk.com
Referer: http://www.cnblogs.com/birdshome/archive/2005/03/11/113723.html
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
2、Windows 2003 + SP1 (NT 5.2)
Connection: Keep-Alive
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: zh-cn
Host: zhilee.aehk.com
Referer: http://www.cnblogs.com/bluefee/archive/2005/03/28/127455.html
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)
UA-CPU: x86
这两个UA string和普通的UA string最大区别就是,里面多了一个"SV1"标志,这个是什么意思呢?SV1的本意是"Security Version 1",它就是用来专门标注使用IE6浏览器的用户使用的操作系统是否是XPSP2或WS03SP1。
既然XPSP2和WS03SP1对IE6有影响,为什么不提升IE的版本号,而是单独使用SVX标注呢?IE开发团队是这么解释的,他们说虽然这两个操作系统的补丁对IE6的设置有影响,但是并没有修改IE6本身的任何功能,比如呈现、DHTML和DOM等。所以这样的一些安全设置不适合升级IE本身的版本号。
在后续的IE版本中,SVX标志可能会被移除,所以目前我们使用UA string检测操作系统的SP版本,只是一个临时的办法。
var ua = navigator.userAgent;
if ( ua.indexOf("SV1") != -1 )
{
if ( ua.indexOf("NT 5.1") != -1 )
{
// windows xp + sp2
}
else if ( ua.indexOf("NT 5.2") != -1 )
{
// windows 2003 + sp1
}
else
{
// wrong user agent string
}
}