uploadify"ID SWFUpload_0 is already in use..."错误的解决方法

本文介绍了解决在多个页面同时加载包含Uploadify组件时出现的ID冲突问题。通过将Flash对象的名字改为基于当前时间戳生成,确保了每个实例的唯一性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在使用 uploadify时 遇到同时加载的多个页面中包含uploadify组件时就会出现“ID SWFUpload_0 is already in use. The Flash Object could not be added”的错误,分析代码就会发现,时因为名字累加的问题,解决方法如下

SWFUpload.prototype.initSWFUpload = function (settings) {
try {
    this.customSettings = {};   // A container where developers can place their own settings associated with this instance.
    this.settings = settings;
    this.eventQueue = [];

    //this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
    //名称重复  SWFUpload.movieCount++不能有效累加导致出现重名现象
    //this.movieName = "SWFUpload_" + parseInt(100*Math.random());
    //,从而修改为随机数   modify by 志超 2015.05.21
    var mydate = new Date();
    this.movieName = "SWFUpload_" + mydate.getTime().toString();

//,从而修改为随机数 modify by 志超 2015.09.07

    this.movieElement = null;


        // Setup global control tracking
    SWFUpload.instances[this.movieName] = this;

    // Load the settings.  Load the Flash movie.
    this.initSettings();
    this.loadFlash();
    this.displayDebugInfo();
} catch (ex) {
    delete SWFUpload.instances[this.movieName];
    throw ex;
}
};
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值