问题:使用uploadify组件时,当一个页面多次加载这个组件的时候,就会报这个错,ID SWFUpload_0 is already in use. The Flash Object could not be added;大概的意思就是ID重复了。查找了一下解决办法记录一下。
解决方案:修改uploadify.js中的一段代码
SWFUpload.prototype.initSWFUpload = function(b) {
try {
this.customSettings = {};
this.settings = b;
this.eventQueue = [];
this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
this.movieElement = null;
SWFUpload.instances[this.movieName] = this;
this.initSettings();
this.loadFlash();
this.displayDebugInfo()
} catch(a) {
delete SWFUpload.instances[this.movieName];
throw a
}
};
就是这句,将加号后面的换成可以唯一标识的就可以了,比如系统当前时间。
var mydate = new Date();
this.movieName = "SWFUpload_" + mydate.getTime().toString();