'__flash__removeCallback' undefined when deleting a DOM element using Youtube iframe

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> 

I am changing the contents of #container with ajax call

 $.get(url, function(data) { ('#container').html(data); } 

Now I get the following error in IE9: "SCRIPT5009:" _flash_removeCallback "- undefined".

I tried removing, deleting, ... a video and / or iframe before calling ajax, but this does not 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 have no idea ...

+8
javascript youtube internet-explorer-9
source share
4 answers

Finally, I got a solution.

I don’t know which server-side language you use, I use PHP. In any case, if the browser is IE9, then use the 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 } ?> 

Briefly use the object tag for IE9 and the iframe to relax.

+2
source share

I got a solution.

 ytplayer.getIframe().src=''; 
+1
source share

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

 $('#video iframe').removeAttr('src') 
+1
source share

I got the same error and came to my own decision. I felt that using the old "object" solution for IE9 / IE10 is not a true solution, because you will never have to write code specifically for one browser.

The difference is in my situation, I just needed a video to pop up, and then stopped playing and disappeared when I clicked the close button.

Using the provided code ...

 function playVideo() { $('#video iframe').attr('src', 'http://www.youtube.com/embed/VIDEO_ID_HERE'); $('#video iframe').fadeIn(); } function stopVideo() { $('#video iframe').attr('src', ''); $('#video').fadeOut(); } 
0
source share

All Articles