JQuery(可能是 SWFObject)没有执行 IE 7.0.5730.13 或 8.0.6001.18702 或 8.0.7100.0 中应该执行的操作,但可以在 7.0.5730.11 中运行

发布于 2024-08-01 20:35:21 字数 3964 浏览 3 评论 0原文

我有一个网站,上面运行着 jQuery 和 SWFObject。 页面加载时,它会设置 2 秒超时,然后触发 SWFObject 实例加载影片。 当电影结束时,玩家会回调 JS 来触发另一部电影。 另一部电影加载良好并播放。 播放完毕后,第二部电影也应该触发另一个回调,但事实并非如此。 我认为问题在于,在第二个电影初始化时,它应该清除前一个元素并重置它,以便 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"
});
};

I have a website that has jQuery and SWFObject running on it. When the page loads, it sets a 2 second timeout then triggers an SWFObject instance to load a movie. When the movie finishes it's player callsback to JS to trigger another movie. The other movie loads fine and plays. When it's done playing, the second movie is also supposed to trigger another callback, but it doesn't. What I think is the problem is that on the second movie init, it is supposed to clear the previous element and reset it so that SWFObject can reuse it, and even though that is what happens in the DOM, SWFObject doesn't reuse the element. I think this is caused because jQuery still retains a hold of the element somehow even though it's removed from the DOM, which is throwing of IE when SWFObject is trying to reuse it.

I'm attaching my code, so maybe someone might be able to spot where it's not working, or if anyone has a suggestion on how to get jQuery to clear the element from both DOM and the jQuery object.

The code might seem a little unorganized, but this is my first time posting on Stack Overflow, so I don't know how to get it to post all the code properly formatted...

Thanks in advance!

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"
});
};

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

著墨染雨君画夕 2024-08-08 20:35:21

使用通过 xml 文件指定的播放列表不是更好吗?

aren't you better off just using a playlist, specified via an xml file?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文