Html 如何强制 Iframe 在标准父框架下运行怪癖
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11723724/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to force Iframe to run quirks under a standard parent frame
提问by Tal
We have a parent page that must run in IE9 standard mode, executing HTML5 commands. Underneath we have an iframe that must run in compatibility mode (IE7/8).
我们有一个必须在 IE9 标准模式下运行的父页面,执行 HTML5 命令。在我们下面有一个必须在兼容模式 (IE7/8) 下运行的 iframe。
In IE9, as I understand, iframes inherits their doctype from parent. is that correct? Is there any solution for this issue? can , somehow, iframe be executed with quirks doctype under standard mode doctype parent frame? thanks, Tal
在 IE9 中,据我所知,iframe 从父级继承了它们的文档类型。那是对的吗?这个问题有什么解决方案吗?可以,不知何故,在标准模式 doctype 父框架下使用 quirks doctype 执行 iframe?谢谢,塔尔
回答by Nick Blanchard-Wright
It's not possible to trigger a different rendering mode in a child iframe in IE9, as officially documented here: http://msdn.microsoft.com/en-us/library/gg558056(v=vs.85).aspx(emphasis added):
不可能在 IE9 中的子 iframe 中触发不同的呈现模式,如此处正式记录的那样:http: //msdn.microsoft.com/en-us/library/gg558056(v = vs.85).aspx(强调添加):
Although the newer rendering engine is only used when Windows Internet Explorer detects that an HTML page has requested the highest level of support for standards, the same is not always true for child pages that might be loaded within frame and iframe elements. Because only one rendering engine can be active at a time, IE9 Mode also includes emulation for Quirks Mode.
尽管较新的呈现引擎仅在 Windows Internet Explorer 检测到 HTML 页面请求最高级别的标准支持时使用,但对于可能在 frame 和 iframe 元素中加载的子页面并不总是如此。由于一次只能激活一个渲染引擎,因此 IE9 模式还包括对 Quirks 模式的模拟。
However, as it says, you cantrigger "quirks mode emulation"which leaves the IE9 rendering engine active but alters its behavior in several ways to match the old quirks mode.
但是,正如它所说,您可以触发“怪癖模式仿真”,这会使 IE9 渲染引擎保持活动状态,但会以多种方式改变其行为以匹配旧的怪癖模式。
JSBin demo: http://jsbin.com/ozejuk/1/
JSBin 演示:http: //jsbin.com/ozejuk/1/
This example has a div with style background: #ff0000; background: 00ff00; border-radius: 30px
... in quirks mode, hex colors without #
are accepted. In IE9 mode they are not. Loading the demo in IE9 will show a red div in the parent page, and a green div (but still with rounded corners) in the iframe.
这个例子有一个带有样式的 div background: #ff0000; background: 00ff00; border-radius: 30px
... 在 quirks 模式下,不#
接受十六进制颜色。在 IE9 模式下,它们不是。在 IE9 中加载演示将在父页面中显示一个红色 div,在 iframe 中显示一个绿色 div(但仍然带有圆角)。
How to trigger quirks mode emulation in an iframe: http://msdn.microsoft.com/en-us/library/gg558096(v=vs.85).aspx
如何在 iframe 中触发 quirks 模式仿真:http: //msdn.microsoft.com/en-us/library/gg558096(v= vs.85).aspx
Short version: omit DOCTYPE, add: <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
简短版本:省略 DOCTYPE,添加: <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
Complete list of effects quirks mode emulation has on rendering: http://msdn.microsoft.com/en-us/library/gg558047(v=vs.85).aspx
效果怪癖模式仿真对渲染的完整列表:http: //msdn.microsoft.com/en-us/library/gg558047(v= vs.85).aspx