javascript - __flash__removeCallback is undefined errors in IE9 while removing the dom element - Stack Overflow

probably the duplicate of __flash__removeCallback is undefined when deleting DOM element with Youtube i

probably the duplicate of '__flash__removeCallback' is undefined when deleting DOM element with Youtube iframe

I went through some sites but could not found the exact solution of why youtube throws this exception while removing the dom element with youtube iframe and what will be the solution??

Some solution that i have got are :

  1. ytplayer.getIframe().src=''; -> I dont know how this could solve my problem?

2.$('#youtube iframe').attr('src', ''); $('#youtube').remove() -> I have tried this but won't worked.

3.hide iframe before remove the parent element -> won't worked.

Please help me to resolve this issue.

probably the duplicate of '__flash__removeCallback' is undefined when deleting DOM element with Youtube iframe

I went through some sites but could not found the exact solution of why youtube throws this exception while removing the dom element with youtube iframe and what will be the solution??

Some solution that i have got are :

  1. ytplayer.getIframe().src=''; -> I dont know how this could solve my problem?

2.$('#youtube iframe').attr('src', ''); $('#youtube').remove() -> I have tried this but won't worked.

3.hide iframe before remove the parent element -> won't worked.

Please help me to resolve this issue.

Share Improve this question edited May 23, 2017 at 10:24 CommunityBot 11 silver badge asked Apr 8, 2013 at 19:28 Only ROnly R 551 silver badge4 bronze badges 0
Add a ment  | 

4 Answers 4

Reset to default 3

This appears to be an IE9-only bug.

It occurs when a Flash object interacts with a HTML document using JavaScript (ExternalInterface on the Flash/ActionScript-side) and rears it's ugly head when an IFRAME containing the HTML document w/ the Flash Object es into play.

Seeing how you specify you're using the YouTube API, there is sadly nothing you can do to make sure the Flash unregisters itself and won't call JavaScript functions (or vice versa) when it's time to remove it as you rely on third party software running outside your applications domain.

If you don't NEED the YouTube API, but merely a quick way to get a video within your application, the safest bet is to use an old style object embed for IE9 and the API / IFRAME embedding for the rest of the sane world.

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

Removing above object (you can use SWFObject's "embedSWF" and "removeSWF" just fine for this btw) will get the video player off your page, without throwing any _flash_remove.. warnings.

If you NEED the YouTube API / control over the video player state:

Have you tried invoking the "destroy"-method on the ytplayer ? Unvoke the destroy and while I'm reluctant to posting "answers" using timeouts, give the Flash object some time to unregister BEFORE your set the source of the iframe to an empty string (so the document unloads), then clear the iframe or it's parent container.

Though I remember from a previous project this drove us mad (the context being a single-page interface where videos were dynamically added and removed) and we resorted to writing our own Flash player fallback using the AS3 YT code. That's how annoying it got.

The below code should work across all browsers (and not produce the IE9/IE10 error you describe above).

function playVideo() {
    $('#video iframe').attr('src', 'http://www.youtube./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 button is clicked, and will safely remove the video without causing memory leaks in IE9/IE10.

This worked for me in IE9.

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

You can also fix Flash's callback removal function by overwriting it with your own. This issue is not particularly connected to video apps only. In the example below I overwrite it right before the page gets unloaded, but it can happen anytime after the swf loads.

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745329371a4622805.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信