根据标题,我使用 X-UA-Compatible
元标记在当前 IE 版本中强制使用标准模式。 (下面是 HTML)
尽管如此,在 IE9 中,它会在一定比例的用户计算机上进入兼容模式。我使用 Mac,它在 Win7 IE9 虚拟机以及我的 Windows 机器的 IE9 上运行良好。但当我在同事的笔记本电脑上测试时,它直接进入兼容性 View 。
我尝试了以下元标记,但没有成功:
-
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7">
-
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
-
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
我尝试使用 this answer 重置 Internet Explorer 设置对于同样的问题,它仍然不起作用。
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7">
<title>Site</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
...
最佳答案
微软 specifies that a comma应该使用示例代码片段中的分号来分隔每种模式,如下所示:
<meta http-equiv="X-UA-Compatible" content="IE=9,8,7">
但我怀疑,如果您已经单独尝试过 content="IE=edge"
,那么这可能不是重点。第二种解决方案是完全避免使用元标记,而是将 X-UA-Compatible 作为 HTTP header 发送。
如果这不起作用,我会检查你同事笔记本电脑中的网络设置(不仅仅是 IE 的设置),看看他的网络是否被视为 Intranet,尽管它不是 Intranet。
关于html - 即使使用 X-UA 元标记,IE9 也会进入 IE7 兼容性 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30509230/