<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>

在除IE之外的每个浏览器中,所有这4个测试都有效。在IE 6和7下,最后一个失败并显示一个空帧。 是否有允许IE在对象中加载外部html的解决方法?

有帮助吗?

解决方案

有关如何在IE中使用Object的更多信息,请查看以下内容: http://aplus.rs/web-dev/insert-html-page-into-another-html-page/

归结为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]-->

请注意,classid特定于您尝试服务的内容类型。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top