JQuery(可能是SWFObject)在IE 7.0.5730.13或8.0.6001.18702或8.0.7100.0中没有做到它应该做的,但是在7.0.5730.11中工作

时间:2009-08-07 18:58:23

标签: jquery internet-explorer swfobject

我有一个运行jQuery和SWFObject的网站。页面加载时,它设置2秒超时,然后触发SWFObject实例加载电影。当电影结束时,玩家回调JS以触发另一部电影。另一部电影加载精细并播放。当它完成播放时,第二部电影也应该触发另一个回调,但事实并非如此。我认为问题在于,在第二个电影init上,它应该清除前一个元素并重置它以便SWFObject可以重用它,即使这是在DOM中发生的事情,SWFObject也不会重用该元素。我认为这是因为jQuery仍然以某种方式保留了元素,即使它已从DOM中移除,当SWFObject试图重用它时抛出IE。

我正在附加我的代码,所以也许有人可能会发现它不起作用的地方,或者是否有人建议如何让jQuery从DOM和jQuery对象中清除元素。

代码可能看起来有点无组织,但这是我第一次发布Stack Overflow,所以我不知道如何让它发布所有正确格式化的代码......

提前致谢!

var Shadow;
var ActorWrapper, VideoWrapper;
var Actor, Video;
var Navigation;
var Flash, Random;
var t;

$(document).ready(function () {
if (jQuery.browser.msie && jQuery.browser.version <= 6) {
    $(".Body").supersleight();
};

t = window.setTimeout(function () {
    window.clearTimeout(t);

    Flash = $("#Flash");

    if (Boolean(Flash.val())) {
        Shadow = $("#Shadow");
        ActorWrapper = $("#ActorWrapper");
        Actor = $("#Actor");
        VideoWrapper = $("#VideoWrapper");
        Video = $("#Video");
        Random = $("#Random");
        Navigation = $(".Navigation");

        VideoWrapper.css({
            left: parseInt(($(document).width() - 400) / 2),
            top: parseInt(($(window).height() - 300) / 2)
        });

        IncomingActor();
    };
}, 2000);
});

var IncomingActor = function () {
ActorWrapper.css({
    display: "block",
    height: 325,
    left: parseInt((($(window).width() - 714) / 2) - 46),
    width: 180
});

swfobject.embedSWF("/Resources/Flash/Player.swf", "Actor", "180", "325", "9", null, {
    Path: "Amy-1.flv",
    Callback: "Vid",
    Buffer: 2,
    Width: 180,
    Height: 325
}, {
    play: true,
    loop: false,
    quality: "best",
    wmode: "transparent",
    swliveconnect: true,
    allowscriptaccess: "always"
});

Navigation.css({
    textAlign: "right"
});
};

var Vid = function () {
$("#Actor").remove();
$("#ActorWrapper").html("<div id=\"Actor\"></div>");

VideoWrapper.css({
    display: "block"
});

Shadow.css({
    display: "block",
    height: $(document).height(),
    width: $(document).width()
}).animate({
    opacity: 0.6
}, 1000).click(function () {
    VideoWrapper.animate({
        opacity: 0
    }, 500);

    t = window.setTimeout(function () {
        window.clearTimeout(t);

        VideoWrapper.css({
            display: "none"
        });

        Shadow.animate({
            opacity: 0
        }, 500);

        t = window.setTimeout(function () {
            window.clearTimeout(t);

            Shadow.css({
                display: "none"
            });
        }, 500);
    }, 500);
});

swfobject.embedSWF("/Resources/Flash/Player.swf", "Video", "400", "300", "9", null, {
    Path: (Random.val() + ".flv"),
    Callback: "OutgoingActor",
    Buffer: 2,
    Width: 400,
    Height: 300
}, {
    play: true,
    loop: false,
    quality: "best",
    wmode: "transparent",
    swliveconnect: true,
    allowscriptaccess: "always"
});

VideoWrapper.animate({
    opacity: 1
});

Navigation.css({
    textAlign: "center"
});
};

var OutgoingActor = function () {
ActorWrapper.css({
    left: (parseInt(ActorWrapper.css("left")) + 10)
});

VideoWrapper.animate({
    opacity: 0
}, 500);

t = window.setTimeout(function () {
    window.clearTimeout(t);

    VideoWrapper.css({
        display: "none"
    });

    Shadow.animate({
        opacity: 0
    }, 500);

    t = window.setTimeout(function () {
        window.clearTimeout(t);

        Shadow.css({
            display: "none"
        });
    }, 500);
}, 500);

swfobject.embedSWF("/Resources/Flash/Player.swf", "Actor", "180", "325", "9", null, {
    Path: "Amy-2.flv",
    Callback: "RemoveOutgoingActor",
    Buffer: 2,
    Width: 180,
    Height: 325
}, {
    play: true,
    loop: false,
    quality: "best",
    wmode: "transparent",
    swliveconnect: true,
    allowscriptaccess: "always"
});

Navigation.css({
    textAlign: "right"
});
};

1 个答案:

答案 0 :(得分:0)

你最好只使用通过xml文件指定的播放列表吗?