Internet Explorer是否删除了< object>来自DOM的元素? [英] Does Internet Explorer remove the <object> element from DOM?

查看:163
本文介绍了Internet Explorer是否删除了< object>来自DOM的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面中有标记,其中包含标记:

I have markup in my page that includes the tag:

<body>
  <object codebase="blah" codetype="text/blah">
    <param name="name" value="value"/>
    <div>Some Markup</div>
  </object>
</body>

想法是让浏览器显示< div>的内容默认情况下,但是如果存在一个特殊的JS库,它将找到所有元素并转换它关注的元素(基于 @codetype )。

The idea is for browsers to display the content of the <div> by default, but if a special JS library is present, it will find all the elements and transform the ones it cares about (based on @codetype).

这适用于Firefox和WebKit,但在IE中失败,因为该浏览器似乎剥离了外部< object> 元素,只留下内部< div> 。也就是说,在Explorer下,我从上面的标记得到的DOM如下所示:

This works in Firefox and WebKit, but fails in IE, because that browser seems to strip off the outer <object> element, and just leaves the inner <div>. That is, under Explorer, the DOM I get from the above markup looks like this:

<body>
  <div>Some Markup</div>
</body>

这是记录在案的行为吗?有没有办法让IE保持DOM中的< object> 元素不变? (我目前正在使用IE7进行测试。)

Is this a documented behavior? Is there any way to make IE preserve the <object> element in the DOM untouched? (I am currently testing this with IE7.)

注意:这不适用于嵌入Flash或类似的多媒体。

Note: This isn't for embedding Flash, or similar multimedia.

推荐答案

嗯...根据 MSDN ,版本7之前的Internet Explorer将从DOM中删除任何< object> 其内容无法呈现。

Hmm... According to a post on MSDN, Internet Explorer before version 7 would remove from DOM any <object> whose content couldn't be rendered.

我想这会让我的问题变成一个问题22。我可以添加一些数据,使IE呈现< object> (例如让它显示1像素图像),这将启用DOM中的元素,但是这会隐藏后备标记。

I guess this makes my problem a catch-22. I can add some data that would make IE render the <object> (such as make it show a 1 pixel image), which would enable the Element in the DOM, but this would hide the "fallback" markup.

这篇关于Internet Explorer是否删除了&lt; object&gt;来自DOM的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆