【问题标题】:Embedding text/html in an Object (instead of an iframe)在对象中嵌入文本/html(而不是 iframe)
【发布时间】:2010-09-23 14:38:36
【问题描述】:
<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?

【问题讨论】:

标签: html internet-explorer iframe cross-browser cross-domain


【解决方案1】:

查看以下内容以获取有关如何在 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 特定于您尝试提供服务的内容类型。

【讨论】:

  • 如果您尝试从远程服务器拉取内容,Chris 的解决方案在 IE 中不起作用
  • 在 IE8 中运行良好(至少在我的电脑上!)。
  • @RealHowTo:您可能会注意到这个问题和答案都是在 IE8 甚至可用之前发布的..
猜你喜欢
  • 2018-02-26
  • 1970-01-01
  • 2013-05-22
  • 1970-01-01
  • 1970-01-01
  • 2021-05-29
  • 1970-01-01
  • 2011-04-30
  • 2013-10-19
相关资源
最近更新 更多