在html源代码中我有以下内容:
<embed width="100%" id="video-player-flash"...
嵌入IS INSIDE ANrame
如何在运行时访问要附加的嵌入
<embed width="100%" id="video-player-flash" allownetworking="internal"...
感谢
我试过了:
<script type="text/javascript">
jQuery(document).ready( function() {
document.video-player-flash.innerHTML += 'allownetworking="internal"';
});
</script>
OR
<script type="text/javascript">
jQuery(document).ready( function() {
document.getElementById("video-player-flash").innerHTML += 'allownetworking="internal"';
});
</script>
OR
<script type="text/javascript">
jQuery(document).ready( function() {
var playerep = document.getElementById('video-player-flash');
playerep.setAttribute("allownetworking", "internal");
});
</script>
出了什么问题?
我认为问题是youtube视频在另一个域(youtube.com)...所以如何在加载后获取iframe的所有内容,然后完全替换它添加'allownetworking =“internal “”。有可能吗?
答案 0 :(得分:1)
您可以使用:
<script type="text/javascript">
$(document).ready(function(){
$("#video-player-flash").attr("allownetworking", "internal");
});
</script>
您可以在此处阅读jQuery attr
函数:
http://api.jquery.com/attr/
当你使用jQuery时,不需要使用document.getElementById
- 当你想要页面中的选择元素时,你最好使用jQuery选择器。