在对象中嵌入文本/html(而不是 iframe)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/311433/
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
Embedding text/html in an Object (instead of an iframe)
提问by
<iframe data="/localfile.html" type="text/html" width="200" height="200"></iframe>
<iframe data="http://example.com/remotefile.html" type="text/html" width="200" height="200"></iframe>
<object data="/localfile.html" type="text/html" width="200" height="200"></object>
<object data="http://example.com/remotefile.html" type="text/html" width="200" height="200"></object>
Under every browser except IE, all 4 of these tests work. Under IE 6 and 7, the last one fails and shows an empty frame. Is there a workaround that allows IE to load the external html in an object?
在除 IE 之外的所有浏览器下,所有 4 个测试都有效。在 IE 6 和 7 下,最后一个失败并显示一个空帧。是否有允许 IE 在对象中加载外部 html 的解决方法?
采纳答案by NotMe
Review the following for more information about how to use Object with IE: http://aplus.rs/web-dev/insert-html-page-into-another-html-page/
查看以下有关如何在 IE 中使用 Object 的更多信息:http: //aplus.rs/web-dev/insert-html-page-into-another-html-page/
It boils down to a difference in what IE expects versus other browsers. For IE, you have to use the classid attribute instead of the type attribute. For example (from the above referenced site):
它归结为 IE 期望与其他浏览器的差异。对于 IE,您必须使用 classid 属性而不是 type 属性。例如(来自上面引用的站点):
<!--[if IE]>
<object classid="clsid:25336920-03F9-11CF-8FD0-00AA00686F13" data="some.html">
<p>backup content</p>
</object>
<![endif]-->
<!--[if !IE]> <-->
<object type="text/html" data="some.html">
<p>backup content</p>
</object>
<!--> <![endif]-->
Note that the classid is specific to the content type that you are trying to server.
请注意,classid 特定于您尝试提供的内容类型。