sir*_*ark 8 javascript internet-explorer internet-explorer-8
我已经编写了一个Web应用程序,需要IE版本8(或者更高版本).如果我在VM上的干净Windows安装上运行IE8,它会在javascript中使用navigator.userAgent查询时将'MSIE 8.0'报告为用户代理.但是在同事的Windows 7机器上,他的IE在Help | About窗口中报告了版本8,但是用户代理字符串是'MSIE 7.0'.
我认为在他的机器上的某个地方有一个设置告诉IE欺骗以前的版本,我认为某种兼容性设置,但对于我的生活我找不到它.我没有设置quirksmode或IE7兼容模式.
Que*_*tin 12
<meta http-equiv="X-UA-Compatible" content="IE=8">
<script type="text/javascript">
var is_ie8_or_newer = false;
</script>
<!--[if gte IE 8]>
<script type="text/javascript">
is_ie8_or_newer = true;
</script>
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
用户代理不是确定浏览器版本的明智或可靠的方式.为什么不通过仅使用IE8来查找所需功能并使用它?这是一种更可靠的方法.