加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

IE标准模式下关闭带Swfupload插件的ArtDialog时报"__flash__

发布时间:2020-12-15 17:28:16 所属栏目:百科 来源:网络整理
导读:问题描述 使用swfupload作为上传组件,artdialog作为弹出窗口,在关闭弹出窗口时,提示“ __flash__removeCallback ”未定义错误。 原因 swfupload中的flash对象销毁前时会回调 __flash__removeCallback 函数,该函数的定义如下: // Fix Flashes own cleanup

问题描述

使用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();

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读