0

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>

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

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>

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

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


<a href="http://something.com" onclick="return confirmAction()">try to click, I dare you</a>

with the function

function confirmAction(){
      var confirmed = confirm("Are you sure? This will remove this entry forever.");
      return confirmed;
}

(you can also return the confirm right away, I separated it for the sake of readability)

Tested in FF, Chrome and IE

4

3 に答える 3

2

うーん... MSDNの投稿によると、バージョン 7 より前の Internet Explorer<object>は、コンテンツをレンダリングできなかったものをDOM から削除していました。

これにより、私の問題がキャッチ22になると思います。IE にレンダリングさせるデータ<object>(1 ピクセルの画像を表示させるなど) を追加することはできます。これにより、DOM で要素が有効になりますが、これにより「フォールバック」マークアップが非表示になります。

于 2009-06-11T16:07:19.480 に答える
0

To embed objects, I'd recommend using a library like swfobject, because yes, IE is definitively doing something funky with this tag.

于 2009-06-11T15:38:10.067 に答える
0

オブジェクトを作成しようとしてインスタンス化できない場合、オブジェクト タグが最終的に DOM の一部にならなかったとしても、私は驚かないでしょう。

于 2009-06-11T15:45:20.220 に答える