我有一个运行 Sharepoint 2007 的站点。SP 2007 的母版页没有 DOCTYPE,因此以怪异模式呈现。我在 Sharepoint 内的 iframe 中嵌入了另一个网站。该网站更加现代——HTML5 DOCTYPE 和 IE=Edge 的 X-UA 兼容元。
所以,我试图了解 iframe 内容在各种 IE 浏览器中呈现的模式。
据我所知,在 <= IE8 中,父级 (Sharepoint) 将以怪异模式呈现,框架将以标准模式呈现。这就是我想要的。
但是,在IE9+中,会发生什么呢?下面的引用文献似乎认为我的框架将以 Quirks 模式开始渲染,这会很糟糕。如果我将 IE8 的 X-UA 兼容元数据放入 Sharepoint 的 master 中,这会让我在 iframe 中恢复标准模式吗?
编辑:在 IE10 中,我测试了父级的各种配置(带 doctype 和不带 doctype,以及带各种元),并得到了以下结果:
- IE10/doctype/无元:10 个标准/10 个标准
- IE10/无文档类型/元边缘:10 个标准/10 个标准
- IE10/无 doctype/meta 9:9 个标准/9 个标准
- IE10/无文档类型/meta 8:8 个标准/8 个标准
- IE10/no doctype/meta 5:5 个怪癖/8 个标准
- IE10/无文档类型/无元:10 个怪癖/10 个标准
一些有用的链接:
- Will an iframe render in quirks mode?
- How to disable Compatibility View in IE
- iframe not rendering in ie9 mode when containing page is in quirks mode
IE 有时让我想跳桥。
最佳答案
iframe 将以与包含页面相同的模式呈现,无论任何元标记或文档类型设置如何。我还注意到使用开发工具手动更改文档或浏览器模式时会出现混合结果,因此不要依赖于此。如果您想 super 安全,请在更改文档模式时加载新的浏览器选项卡 - 我不相信它!
我制作的这个快速页面将为您提供所需的兼容性信息:http://stevesspace.com/test/quirks/modern.html
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<title>Inner page</title>
<style>
.pass
{
color: green;
}
.fail
{
color: red;
font-weight: bold;
}
#quirks-mode
{
color: #fff;
color: f00;
}
#not-quirks-mode
{
color: green;
color: fff;
}
</style>
</head>
<body>
<div>Quirks Mode: <span id="quirks-mode">true</span><span id="not-quirks-mode">false</span></div>
<div>Javascript: <span id="scripts-enabled" class="fail">false</span></div>
<div>Array map support: <span id="array-map" class="fail">false</span></div>
<hr />
<div>Doc Mode: <span id="doc-mode"></span></div>
<div>Compat Mode: <span id="compat-mode"></span></div>
<hr />
<div>SVG Circle should render below</div>
<svg>
<circle cx="50" cy="50" r="50" style="fill: green;"/>
</svg>
</body>
<script type="text/javascript">
document.getElementById('doc-mode').innerHTML += document.documentMode;
document.getElementById('compat-mode').innerHTML += document.compatMode;
document.getElementById('scripts-enabled').innerHTML = 'true';
document.getElementById('scripts-enabled').className = 'pass';
if (Array.prototype.map) {
document.getElementById('array-map').innerHTML = 'true';
document.getElementById('array-map').className = 'pass';
}
</script>
</html>
关于html - 什么模式在 Sharepoint 2007 中呈现 iframe(即怪异模式)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16367329/