JS 切换 embed 的 src 值

今天在工作中遇到需要js动态的改变embed的src值进行切换的效果;

<div class="m-video">
    <div class="v-play">
        <embed allowfullscreen="true" allowscriptaccess="always" height="450" name="cc_4B7838C6838BB3B99C33DC5901307461" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://p.bokecc.com/flash/player.swf?vid=4B7838C6838BB3B99C33DC5901307461&amp;siteid=4F21A251DAE61656&amp;autoStart=false&amp;playerid=08C25F053497D927&amp;playertype=2" type="application/x-shockwave-flash" width="660" wmode="transparent"></embed>
    </div>
    <ul class="v-tit">
        <li data-src="http://p.bokecc.com/flash/player.swf?vid=4B7838C6838BB3B99C33DC5901307461&amp;siteid=4F21A251DAE61656&amp;autoStart=true&amp;playerid=08C25F053497D927&amp;playertype=2"><img src="http://u1.huatu.com/image/2014image/201510/zgzx/ztfx1.jpg" alt=""></li>
        <li data-src="http://p.bokecc.com/flash/player.swf?vid=1A42E7BBB7A33C6A9C33DC5901307461&amp;siteid=4F21A251DAE61656&amp;autoStart=true&amp;playerid=08C25F053497D927&amp;playertype=2"><img src="http://u1.huatu.com/image/2014image/201510/zgzx/haiguan1.jpg" alt=""></li>
        <li data-src="http://p.bokecc.com/flash/player.swf?vid=7A911A9BDBD30B2D9C33DC5901307461&amp;siteid=4F21A251DAE61656&amp;autoStart=true&amp;playerid=08C25F053497D927&amp;playertype=2"><img src="http://u1.huatu.com/image/2014image/201510/zgzx/haishiju1.jpg" alt=""></li>
    </ul>
</div>

点击下边的列表,上边的视频刷新播放:

$(document).ready(function(){
    //点击右边列表的某个链接,视频播放切换
    $('.m-video .v-tit').find('li').each(function(i, elem){
        $(this).click(function(){
            $('.m-video .v-play > embed').attr('src', $(this).attr('href'));
            return false;
        });
        //document.getElementById('evideo').play();
    });
});

这样只能切换embed的src值,但并不会切换播放(奇怪firefox能够切换播放,其它浏览器只能改变了src),就是没有触发视频的play动作,但因为不是html5的

$(document).ready(function(){
    //点击右边列表的某个链接,视频播放切换
    $('.m-video .v-tit').find('li').each(function(i, elem){
        $(this).click(function(){
            $('.m-video .v-play > embed').remove();
            var vPlayTxt = '<embed allowfullscreen="true" allowscriptaccess="always" height="450" name="cc_4B7838C6838BB3B99C33DC5901307461" pluginspage="http://www.macromedia.com/go/getflashplayer" src="' + $(this).attr('data-src') + '" type="application/x-shockwave-flash" width="660" wmode="transparent"></embed>';
            $('.m-video .v-play').html(vPlayTxt);
            return false;
        });
    });
});
发表评论
* 昵称
* Email
* 网址
* 评论