Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 检测早于8的IE版本_Html_Internet Explorer - Fatal编程技术网

Html 检测早于8的IE版本

Html 检测早于8的IE版本,html,internet-explorer,Html,Internet Explorer,我的HTML中有以下代码: <!--[if lt IE 8]> <script language="javascript"> alert("This page does not display properly in versions of Internet Explorer earlier than 8.\nPlease upgrade to IE8 (or later)."); </script> <![endif]--> 但是,即使使用

我的HTML中有以下代码:

<!--[if lt IE 8]>
<script language="javascript">
alert("This page does not display properly in versions of Internet Explorer earlier than 8.\nPlease upgrade to IE8 (or later).");
</script>
<![endif]-->

但是,即使使用IE8访问页面,也会触发警报,无论IE8是否在兼容性视图中

任何建议都将不胜感激


注意。

好吧,公司视图(Quirksmode)不足以测试IE的东西。你需要IE F12(开发者)工具-默认情况下应该包括它们。在那里,您可以选择为页面使用哪个版本的IE(浏览器模式)。它一直对我有用。当然,它不是100%准确,但它是最接近IE以前版本的实际副本。当然,Comp View(Quirksmode)不足以测试IE内容。你需要IE F12(开发者)工具-默认情况下应该包括它们。在那里,您可以选择为页面使用哪个版本的IE(浏览器模式)。它一直对我有用。当然,它不是100%准确,但它是最接近IE以前版本的实际副本。您可以在CSS中放入一些特定于版本的样式,然后使用JavaScript检测它们

.test {
  margin-left: 8px;  --> for all browsers
  _margin-left: 6px; --> for ie6
  #margin-left: 7px; --> for ie7 and below
}

查询出marginleft的值,然后您可以轻松地检测IE7和IE6。

您可以在CSS中放入一些特定于版本的样式,然后使用JavaScript检测它们

.test {
  margin-left: 8px;  --> for all browsers
  _margin-left: 6px; --> for ie6
  #margin-left: 7px; --> for ie7 and below
}
查询出剩余边距的值,然后您就可以轻松地检测IE7和IE6