IE标准模式下关闭带Swfupload插件的ArtDialog时报"__flash__removeCallback"未定义错误

来源:互联网 发布:mediainfo linux 安装 编辑:程序博客网 时间:2024/06/04 19:07

问题描述

使用swfupload作为上传组件,artdialog作为弹出窗口,在关闭弹出窗口时,提示“__flash__removeCallback”未定义错误。

原因

swfupload中的flash对象销毁前时会回调__flash__removeCallback函数,该函数的定义如下:

// Fix Flashes own cleanup code so if the SWFMovie was removed from the page// it doesn't display errors.window["__flash__removeCallback"] = function (instance, name) {try {if (instance) {instance[name] = null;}} catch (flashEx) {}};
关闭artdialog窗口时,页面的js等内容也随iframe一起销毁掉,故找不到__flash__removeCallback函数的定义。

解决方法

方法一:在关闭artdialog前,直接调用swfupload中的cleanUp函数清除影片绑定的函数,此种方法逻辑上可行但本人测试失败,测试代码如下:

var movieElement = swfupload.getMovieElement();swfupload.cleanUp(movieElement);art.dialog.close();

cleanUp函数定义如下:

// Private: removes Flash added fuctions to the DOM node to prevent memory leaks in IE.// This function is called by Flash each time the ExternalInterface functions are created.SWFUpload.prototype.cleanUp = function (movieElement) {// Pro-actively unhook all the Flash functionstry {if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IEthis.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");for (var key in movieElement) {try {if (typeof(movieElement[key]) === "function") {movieElement[key] = null;}} catch (ex) {}}}} catch (ex1) {}// Fix Flashes own cleanup code so if the SWFMovie was removed from the page// it doesn't display errors.window["__flash__removeCallback"] = function (instance, name) {try {if (instance) {instance[name] = null;}} catch (flashEx) {}};};

方法二:在关闭artdialog前,直接移除movieElement对象,测试失败。

var movieElement = swfupload.getMovieElement();$(movieElement).remove();

方法三:在关闭artdialog前移除movieElement对象的父对象,测试成功。

var movieElement = swfupload.getMovieElement();$(movieElement).prarent().remove();



0 0