您的位置:首页 > 其它

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

2015-01-13 16:16 330 查看

问题描述

使用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 functions
try {
if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
this.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();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: