在IE/Chrome中动态更改嵌入式视频src(适用于Firefox)

mac*_*ca1 8 javascript embed video jquery

我正在尝试动态更改页面上的嵌入视频.它在Firefox中工作但由于某种原因它不适用于IE和Chrome(奇怪的组合).这是HTML:

   <object id="viewer" width="575" height="344">
        <param name="wmode" value="transparent" />
        <param name="movie" value="http://www.youtube.com/v/Lmn94kn08Lw&hl=en&fs=1&color1=0x006699&color2=0x54abd6&rel=0" />
        <param name="allowFullScreen" value="true" />
        <embed id="embeddedPlayer" src="http://www.youtube.com/v/Lmn94kn08Lw&hl=en&fs=1&color1=0x006699&color2=0x54abd6&rel=0" type="application/x-shockwave-flash" allowfullscreen="true" width="575" height="344" wmode="transparent"></embed>
    </object>
Run Code Online (Sandbox Code Playgroud)

这是我的javascript代码.单击链接以更改视频:

        $("#video a").click(
            function() {
                var videoAddress = $(this).attr("href");
                $("#embeddedPlayer").attr("src", videoAddress);
                return false; // stop the default link so it just reloads in the video player
            }
        );
Run Code Online (Sandbox Code Playgroud)

就像我说的那样,视频在Firefox中完美变化,但在IE和Chrome中没有任何反应.有任何想法吗?

mac*_*ca1 10

最后想出了适用于IE,Firefox和Chrome的东西.

这样做似乎有点不寻常,但它适用于IE8/Firefox/Chrome,所以对我来说听起来不错.

$("#video a").click(
            function() {
                var videoAddress = $(this).attr("href");

                $("#media-active").html(" ");
                $("#media-active").html('<object id="viewer" width="575" height="344"><param name="wmode" value="transparent" />' +
        '<param name="movie" value="' + videoAddress + '" /><param name="allowFullScreen" value="true" />' +
        '<embed id="embeddedPlayer" src="' + videoAddress + '" type="application/x-shockwave-flash" allowfullscreen="true" width="575" height="344" wmode="transparent"></embed></object>');

                return false; // stop the default link so it just reloads in the video player
            }
);
Run Code Online (Sandbox Code Playgroud)