__flash__removeCallback are undefined errors in IE9 when deleting a dom element

Probably a duplicate of '__ flash__removeCallback' undefined when deleting a DOM element using Youtube iframe

I went through some sites, but could not find the exact solution, why youtube throws this exception by removing the dom element using ifutube iframe and what will be the solution?

Some solution that I have:

  • ytplayer.getIframe().src=''; β†’ I do not know how this could solve my problem?

2. $('#youtube iframe').attr('src', ''); $('#youtube').remove() $('#youtube iframe').attr('src', ''); $('#youtube').remove() β†’ I tried this but did not work.

3.hide iframe before deleting parent β†’ will not work.

Please help me solve this problem.

+4
source share
4 answers

This is apparently a IE9 bug.

This happens when a Flash object interacts with an HTML document using JavaScript (ExternalInterface from the Flash / ActionScript side) and returns its ugly head when an IFRAME containing an HTML document with Flash Object is launched into the game.

After seeing how you indicate that you are using the YouTube API, you have nothing to do to make sure Flash has canceled itself and will not call JavaScript functions (or vice versa) when the time comes to uninstall it, as you rely on third-party software running outside your application domain.

If you don’t need the YouTube API, but just a quick way to get the video in your application, the safest option is to use the old style object for IE9 and the API / IFRAME attachment for the rest of the healthy world.

 <object width="{WIDTH}" height="{HEIGHT}"> <embed src="https://www.youtube.com/v/{VIDEO_ID}?version=3&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" width="{WIDTH}" height="{HEIGHT}"></embed> </object> 

Removing the above object (you can use SWFObject "embedSWF" and "removeSWF", which is great for this by the way), remove the video player from your page without throwing any _flash_remove warnings ..

If you need the YouTube API / video player control:

Have you tried calling the destroy method on ytplayer? Unvoke the destroy, and while I don’t want to post β€œresponses” using timeouts, give the Flash object some time to unregister before you set the iframe source to an empty line (so that the document is unloaded), then clear the iframe or its parent container.

Although I remember from a previous project, it drove us crazy (the context was a one-page interface where the video was dynamically added and removed), and we resorted to writing our own backup Flash player using AS3 YT code. That's how annoying it is.

+3
source

The code below should work in all browsers (and not cause the IE9 / IE10 errors described above).

 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(); } 

The end result is a video that will load when the button is pressed and will safely delete the video without causing a memory leak in IE9 / IE10.

+1
source

This worked for me in IE9.

  $(window).unload(function() { jwplayer('video1').stop(); jwplayer('video1').remove(); $(window).remove(); }); 
0
source

You can also fix the Flash callback removal feature by overwriting it yourself. This problem is not particularly related to video applications only. In the example below, I rewrite it just before the page is unloaded, but this can happen anytime after swf loads.

window.onbeforeunload = function () { this.__flash__removeCallback = function (instance, name) { if (instance == null) return; // <-- this line prevents the error instance[name] = null; } }

0
source

All Articles