删除dom元素时,IE9中的__flash__removeCallback是未定义的错误

时间:2022-05-24 04:56:38

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

使用Youtube iframe删除DOM元素时,可能没有定义'__flash__removeCallback'的副本

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??

我经历了一些网站,但无法找到确切的解决方案,为什么youtube抛出此异常,同时用youtube iframe删除dom元素,解决方案是什么?

Some solution that i have got are :

我得到的一些解决方案是:

  1. ytplayer.getIframe().src=''; -> I dont know how this could solve my problem?
  2. 。ytplayer.getIframe()SRC = ''; - >我不知道这怎么能解决我的问题?

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

2。$('#youtube iframe')。attr('src',''); $('#youtube')。remove() - >我试过这个但是不行。

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

3.hide iframe删除父元素之前 - >将无效。

Please help me to resolve this issue.

请帮我解决这个问题。

4 个解决方案

#1


3  

This appears to be an IE9-only bug.

这似乎是一个IE9唯一的错误。

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 comes into play.

当Flash对象使用JavaScript(Flash / ActionScript端的ExternalInterface)与HTML文档交互时会发生这种情况,并且当包含带有Flash对象的HTML文档的IFRAME发挥作用时,它会变得丑陋。

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.

看看你如何指定你正在使用YouTube API,遗憾的是你无法做任何事情来确保Flash取消注册本身并且在你依赖第三方时将其删除时不会调用JavaScript函数(反之亦然)在应用程序域外运行的软件。

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.

如果您不需要YouTube API,但只是在应用程序中获取视频的快捷方式,最安全的选择是使用嵌入IE9的旧样式对象和API / IFRAME嵌入其他理智的世界。

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

删除上面的对象(你可以使用SWFObject的“embedSWF”和“removeSWF”就好了这个顺便说一句)会让视频播放器离开你的页面,而不会抛出任何_flash_remove ..警告。

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

如果您需要YouTube API /控制视频播放器状态:

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.

你试过在ytplayer上调用“destroy”方法吗?撤消销毁,虽然我不愿意使用超时发布“答案”,但是在将iframe的源设置为空字符串(因此文档卸载)之前,请给Flash对象一些时间取消注册,然后清除iframe或者它是父容器。

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.

虽然我记得以前的一个项目,这让我们疯狂(上下文是一个单页界面,视频被动态添加和删除),我们使用AS3 YT代码编写自己的Flash播放器后备。这有点令人讨厌。

#2


1  

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

以下代码应适用于所有浏览器(并且不会产生您在上面描述的IE9 / IE10错误)。

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 button is clicked, and will safely remove the video without causing memory leaks in IE9/IE10.

最终结果是在单击按钮时将加载的视频,并将安全地删除视频而不会导致IE9 / IE10中的内存泄漏。

#3


0  

This worked for me in IE9.

这在IE9中对我有用。

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

#4


0  

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.

您还可以通过使用自己的方法覆盖Flash来修复Flash的回调删除功能。此问题与视频应用无关。在下面的示例中,我在页面卸载之前覆盖它,但它可以在swf加载后的任何时候发生。

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

window.onbeforeunload = function(){this .__ flash__removeCallback = function(instance,name){if(instance == null)return; // < - 此行可防止错误实例[name] = null; }}

#1


3  

This appears to be an IE9-only bug.

这似乎是一个IE9唯一的错误。

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 comes into play.

当Flash对象使用JavaScript(Flash / ActionScript端的ExternalInterface)与HTML文档交互时会发生这种情况,并且当包含带有Flash对象的HTML文档的IFRAME发挥作用时,它会变得丑陋。

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.

看看你如何指定你正在使用YouTube API,遗憾的是你无法做任何事情来确保Flash取消注册本身并且在你依赖第三方时将其删除时不会调用JavaScript函数(反之亦然)在应用程序域外运行的软件。

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.

如果您不需要YouTube API,但只是在应用程序中获取视频的快捷方式,最安全的选择是使用嵌入IE9的旧样式对象和API / IFRAME嵌入其他理智的世界。

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

删除上面的对象(你可以使用SWFObject的“embedSWF”和“removeSWF”就好了这个顺便说一句)会让视频播放器离开你的页面,而不会抛出任何_flash_remove ..警告。

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

如果您需要YouTube API /控制视频播放器状态:

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.

你试过在ytplayer上调用“destroy”方法吗?撤消销毁,虽然我不愿意使用超时发布“答案”,但是在将iframe的源设置为空字符串(因此文档卸载)之前,请给Flash对象一些时间取消注册,然后清除iframe或者它是父容器。

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.

虽然我记得以前的一个项目,这让我们疯狂(上下文是一个单页界面,视频被动态添加和删除),我们使用AS3 YT代码编写自己的Flash播放器后备。这有点令人讨厌。

#2


1  

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

以下代码应适用于所有浏览器(并且不会产生您在上面描述的IE9 / IE10错误)。

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 button is clicked, and will safely remove the video without causing memory leaks in IE9/IE10.

最终结果是在单击按钮时将加载的视频,并将安全地删除视频而不会导致IE9 / IE10中的内存泄漏。

#3


0  

This worked for me in IE9.

这在IE9中对我有用。

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

#4


0  

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.

您还可以通过使用自己的方法覆盖Flash来修复Flash的回调删除功能。此问题与视频应用无关。在下面的示例中,我在页面卸载之前覆盖它,但它可以在swf加载后的任何时候发生。

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

window.onbeforeunload = function(){this .__ flash__removeCallback = function(instance,name){if(instance == null)return; // < - 此行可防止错误实例[name] = null; }}