0

我通过 jQuery 成功地将 html 插入到元素中而没有问题。问题是对象从不渲染/播放/显示。这是我的代码:

<script>
player='<object id="myPlayer" class="myPlayer">';
player+='<param name="bgcolor" value="#FFFFFF" /></object>';
$("#player").append(player);
</script>
<div id="player"></div>

插入 html 元素后,此代码的结果是正确的,但它永远不会呈现。

如果您加载了没有通过 jQuery 插入的对象的页面,我该如何插入并让它呈现呢?

4

2 回答 2

1

Try appending the object after the div#player is loaded (or in a ready/ondomload handler). I'm betting that your script is run before div#player loads which is why it doesn't show.

<script>
$(document).ready(function(){
   player='<object id="myExperience" class="BrightcoveExperience">';
   player+='<param name="bgcolor" value="#FFFFFF" /></object>';
   $("#player").append(player); /* or equivalent vanilla js                 
                                 * document.getElementById("player").innerHtml = player;
                                 */

})
</script>
<div id='player'></div>
于 2012-05-10T15:34:24.570 回答
0

change inside script:

$("#player").html(player);

w/o jquery

document.getElementById('player').innerHTML = player;
于 2012-05-10T15:33:50.140 回答