处理 swfUpload 实例

发布于 2024-10-30 08:21:32 字数 2283 浏览 0 评论 0原文

我有一个 swfUpload 实例,我想在成功上传后使其消失。我尝试了 destroy 方法,但它导致了很多 javascript 问题。所以我所做的是,当 uploadSuccess 事件触发时,我获取我的 div 并将其显示设置为无。然后我设置另一个 div 的innerHTML 以显示上传视频的缩略图。它在除 Internet Explorer 之外的所有浏览器上都能正常工作,其中显示:

消息:

抛出异常但未捕获行:451 字符:2 代码:0 URI:/js/swfupload/swfupload.js

并且我的表单的提交按钮不起作用。

这是错误的函数

SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
argumentArray = argumentArray || [];

var movieElement = this.getMovieElement();
var returnValue, returnString;

// Flash's method if calling ExternalInterface methods (code adapted from MooTools).
try {
    returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
    returnValue = eval(returnString);
} catch (ex) {
    throw "Call to " + functionName + " failed";
}

// Unescape file post param values
if (returnValue != undefined && typeof returnValue.post === "object") {
    returnValue = this.unescapeFilePostParams(returnValue);
}

return returnValue;

};

以及 uploadSuccess 事件:

function uploadSuccess(file, serverData) {
if (serverData != "")
{
    this.uploadError(file, SWFUpload.UPLOAD_ERROR.HTTP_ERROR, serverData);
}
else
{
    try {
        var progress = new FileProgress(file, this.customSettings.progressTarget);
        progress.setComplete();
        if (this.customSettings.langue == "fr")
        {
            progress.setStatus("Complété.");
        }
        else
        {
            progress.setStatus("Complete.");
        }
        progress.toggleCancel(false);

        document.getElementById("preview").innerHTML = "<div id='cadre-image'><input type='hidden' name='txtFichier' value='" + file.name + "'><img id='imgPreview' src='images/thumbnailVideo.php?src=" + file.name + "&save=true' /><p>" + file.name + "</p></div>";
        document.getElementById("tdAjouter").innerHTML = "<input type='submit' value='Ajouter' />";
        var divupload = document.getElementById("upload");
        divupload.style.display = "none";

    } catch (ex) {
        this.debug(ex);
    }
}

}

I have a swfUpload instance that I want to make disapear after a succesful upload. I tried the destroy method but it caused a lot of javascript problems. So what I did is when the uploadSuccess event fires I get my div and set it's display to none. I then set the innerHTML of another div to show a thumbnail of the uploaded video. It works fine on every browser except internet explorer where it shows :

Message :

Exception thrown and not caught Line : 451 Character : 2 Code : 0
URI : /js/swfupload/swfupload.js

and the submit button of my form doesn't work.

Here is the faulty function

SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
argumentArray = argumentArray || [];

var movieElement = this.getMovieElement();
var returnValue, returnString;

// Flash's method if calling ExternalInterface methods (code adapted from MooTools).
try {
    returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
    returnValue = eval(returnString);
} catch (ex) {
    throw "Call to " + functionName + " failed";
}

// Unescape file post param values
if (returnValue != undefined && typeof returnValue.post === "object") {
    returnValue = this.unescapeFilePostParams(returnValue);
}

return returnValue;

};

And the uploadSuccess event :

function uploadSuccess(file, serverData) {
if (serverData != "")
{
    this.uploadError(file, SWFUpload.UPLOAD_ERROR.HTTP_ERROR, serverData);
}
else
{
    try {
        var progress = new FileProgress(file, this.customSettings.progressTarget);
        progress.setComplete();
        if (this.customSettings.langue == "fr")
        {
            progress.setStatus("Complété.");
        }
        else
        {
            progress.setStatus("Complete.");
        }
        progress.toggleCancel(false);

        document.getElementById("preview").innerHTML = "<div id='cadre-image'><input type='hidden' name='txtFichier' value='" + file.name + "'><img id='imgPreview' src='images/thumbnailVideo.php?src=" + file.name + "&save=true' /><p>" + file.name + "</p></div>";
        document.getElementById("tdAjouter").innerHTML = "<input type='submit' value='Ajouter' />";
        var divupload = document.getElementById("upload");
        divupload.style.display = "none";

    } catch (ex) {
        this.debug(ex);
    }
}

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文