I have a div with a Youtube video embedded via iframe.
<div id="container">
<div id="video">
<iframe width="480" height="360" src="" frameborder="0" allowfullscreen></iframe>
</div>
</div>
I change the content of #container with an ajax call
$.get(url, function(data) {
('#container').html(data);
}
Now I get the following error in IE9: "SCRIPT5009: '_flash_removeCallback' is undefined".
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...
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./embed/LiyQ8bvLzIE" frameborder="0" allowfullscreen></iframe>
</div>
</div>
I change the content of #container with an ajax call
$.get(url, function(data) {
('#container').html(data);
}
Now I get the following error in IE9: "SCRIPT5009: '_flash_removeCallback' is undefined".
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...
Share Improve this question asked Jul 18, 2012 at 14:36 JeroenVdbJeroenVdb 8081 gold badge13 silver badges22 bronze badges 1- im also waiting for this solution very badly :( – coolguy Commented Oct 22, 2012 at 8:14
4 Answers
Reset to default 2Finally I got the solution.
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 } ?>
In short use object
tag for IE9 and iframe
for rest.
I got the solution.
ytplayer.getIframe().src='';
If you still want to continue using the iframe code, you can remove the iframe src by calling removeAttr (instead of trying to set it to blank).
$('#video iframe').removeAttr('src')
I was receiving the same error and came to my own solution. I felt that using the old "object" solution for IE9/IE10 was not a true solution because you should never have to code specifically for one browser.
The difference in my situation, I simply needed a video to pop-up, and then stop playing and disappear when close button was clicked.
Using your provided code...
function playVideo() {
$('#video iframe').attr('src', 'http://www.youtube./embed/VIDEO_ID_HERE');
$('#video iframe').fadeIn();
}
function stopVideo() {
$('#video iframe').attr('src', '');
$('#video').fadeOut();
}