jQuery替换Flash对象参数?

时间:2009-07-28 15:18:02

标签: jquery flash

给出

<div id="dialog" style="display:none; width:100%; vertical-align:middle;">
    <object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="628" height="400">
        <param name="movie" value="../../help/videos/videoplayer.swf" />
        <param name="allowfullscreen" value="true" />
        <param name="allowscriptaccess" value="always" />
        <param name="flashvars" value="file=../../help/videos/video.flv" />
        <object type="application/x-shockwave-flash" data="../../help/videos/videoplayer.swf" width="628" height="400">
            <param name="movie" value="../../help/videos/videoplayer.swf" />
            <param name="allowfullscreen" value="true" />
            <param name="allowscriptaccess" value="always" />
            <param name="flashvars" value="file=../../help/videos/video.flv" />
        </object>
    </object>

为什么不会

$("#dialog").find('<param name="flashvars" value="file=../../help/videos/video.flv" />').replaceWith('<param name="flashvars" value="file=../../help/videos/myfile.flv" />');

工作?

2 个答案:

答案 0 :(得分:3)

您没有通过选择器来查找,您可以执行以下操作:

$('#player param[name=flashvars]').attr('value','new value');

答案 1 :(得分:0)

    var flashhtml = $("object").html();
    $('object').before("<div id='mydiv'>내 div</div>");
    $('object').remove();
    var flashattr = 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="583" height="297">';
    $('#mydiv').html('<object ' + flashattr + '<param name="wmode" value="transparent">' + flashhtml + '</object>');