急!!一个IE版本的怪异问题,请高手不吝赐教!

gzd03 2011-08-09 05:58:39

我的系统是刚做的,IE升级到最新的IE8,版本为:8.0.6001.18702,在js里判断ie版本时出了个问题,代码如下:
<SCRIPT LANGUAGE=javascript>
var i = navigator.appVersion.indexOf("MSIE 8.0");
alert("IE 8?" + " ----- " + i);

i = navigator.appVersion.indexOf("MSIE 7.0");
alert("IE 7?" + " ----- " + i);

i = navigator.appVersion.indexOf("MSIE 6.0");
alert("IE 6?" + " ----- " + i);
</SCRIPT>


输出结果分别:
IE 8? ----- 17
IE 7? ----- -1
IE 6? ----- 81

这里不知道为什么判断是否为IE6时,返回也大于0,不知道是IE哪里设置的问题。请高手帮忙分析,该问题可能出现的原因。谢谢!!

...全文
109 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
gzd03 2011-08-16
  • 打赏
  • 举报
回复
谢谢各位 问题解决了 注册表里标示IE版本的字段多了IE6的内容 具体是什么软件修改的 不清楚

与他人机器的IE8对比过 确实是多了这两条记录 删除后正常

Windows Registry Editor Version 5.00

[HKEY_USERS\S-1-5-21-436374069-839522115-1801674531-500\Software\Microsoft\Windows\CurrentVersion\Internet Settings\User Agent\Post Platform]
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) "=-

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\User Agent\Post Platform]
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) "=-
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 net_lover 的回复:]

IE 8有兼容模式和<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />这些设置,导致在IE8中出现
(compatible; MSIE 6.0; Windows NT 5.1; SV1)
[/Quote]

据我所知,应该不会是这个原因,这个meta仅是告诉ie8,让它用ie7的模式呈现网页,但并不影响用脚本访问用户代理的值。

我测试了,加上和不加上的结果都是

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)

这种问题估计只会在虚拟机中运行的ie有关。
孟子E章 2011-08-09
  • 打赏
  • 举报
回复
IE 8有兼容模式和<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />这些设置,导致在IE8中出现
(compatible; MSIE 6.0; Windows NT 5.1; SV1)
abcd_ufo 2011-08-09
  • 打赏
  • 举报
回复

/**
* 判断浏览器版本
* @return
*/
function Get_IE_Version() {
var v;
if (navigator.userAgent.indexOf("MSIE 6.0") > 0)//IE 6.0
{
v = 6;
} else if (navigator.userAgent.indexOf("MSIE 7.0") > 0)//IE 7.0
{
v = 7
} else if (navigator.userAgent.indexOf("MSIE 8.0") > 0)//IE 8.0
{
v = 8;
} else if (navigator.userAgent.indexOf("MSIE 9.0") > 0)//IE 9.0
{
v = 9;
}
return v;
}





这样写 行
gzd03 2011-08-09
  • 打赏
  • 举报
回复
补充:
使用 navigator.appVersion 得到如下信息,里面有个ie6的版本信息,但在虚拟机的ie8环境里却没有这条信息

4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET……

虚拟机里ie8: 4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET……
yibey 2011-08-09
  • 打赏
  • 举报
回复
不知道神马情况我这里测试出来结果是对的,就是有IE8是17

87,990

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧