使用Youtube iframe删除DOM元素时,'__flash__removeCallback'未定义 [英] '__flash__removeCallback' is undefined when deleting DOM element with Youtube iframe
问题描述
我有一个带有通过iframe嵌入的Youtube视频的div。
I have a div with a Youtube video embedded via iframe.
<div id="container">
<div id="video">
<iframe width="480" height="360" src="http://www.youtube.com/embed/LiyQ8bvLzIE" frameborder="0" allowfullscreen></iframe>
</div>
</div>
我通过ajax调用更改#container的内容
I change the content of #container with an ajax call
$.get(url, function(data) {
('#container').html(data);
}
现在我在IE9中收到以下错误:SCRIPT5009:'_ flash _removeCallback'是未定义。
Now I get the following error in IE9: "SCRIPT5009: '_flash_removeCallback' is undefined".
我尝试在ajax调用之前移除,删除,...视频和/或iframe,但这不起作用:
I tried removing, deleting,... the video and/or iframe before the ajax call but that doesn't work:
<script>
$('#video').html('')
</script>
<script>
$('#video').empty()
</script>
<script>
$('#video').remove()
</script>
<script>
$('#video iframe').attr('src', '')
$('#video').empty()
</script>
<script>
$('#video').hide()
$('#video iframe').attr('src', '')
$('#video').empty()
</script>
...
但现在我已经离开想法......
But now I'm out of idea's...
推荐答案
最后我得到了解决方案。
Finally I got the solution.
我不知道你使用的是哪种服务器端语言,我正在使用PHP。无论如何,如果浏览器是IE9然后使用对象标签。
I don't know which server side language you are using, I'm using PHP. Anyway find if the browser is IE9 then use object tag.
if (preg_match('/MSIE 9.0/', $_SERVER['HTTP_USER_AGENT'])) { /*for IE 9.0 generate with objace tag*/ ?>
<object type="application/x-shockwave-flash" data="VIDEO_URL">
<param name="movie" value="VIDEO_URL" />
</object>
<?php } else { /*rest of all browsers,in iframe*/ ?>
<iframe src="VIDEO_URL"></iframe>
<?php } ?>
简而言之,使用IE9的 object
标签 iframe
休息。
In short use object
tag for IE9 and iframe
for rest.
这篇关于使用Youtube iframe删除DOM元素时,'__flash__removeCallback'未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!