jqueryflashvars

jQuery dynamic file flashvar


With the following code

var $altContent = $elem.children('img').attr('alt');

$('.fp_preview').prepend("<div id='video-flv'>  <object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab' width='720' height='480' id='flv'> <param name='movie' value='WNFlvPlayer.swf' /> <param name='allowfullscreen' value='true' /> <param name='flashvars' value='file='"+
$altContent+
"&autostart=true' /> <embed src='WNFlvPlayer.swf' flashvars='file='"+$altContent+"&autostart=true' allowfullscreen='true' width='720' height='480' name='flv' type='application/x-shockwave-flash' pluginspage='http://www.adobe.com/go/getflashplayer' /> </object> </div>").fadeIn(2000);

I get:

<param 04.flv&autostart="true'" animations="" arch="" renders="" 
value="file=" name="flashvars">

i think is something about nested quotes.


Solution

  • Try this

    var $altContent = $elem.children('img').attr('alt');
    alert($altContent);
    $('.fp_preview').prepend(
    '<div id="video-flv">'+
    '  <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" width="720" height="480" id="flv">'+
    '    <param name="movie" value="WNFlvPlayer.swf" />'+
    '    <param name="allowfullscreen" value="true" />'+
    '    <param name="flashvars" value="file='+$altContent+'&autostart=true" />'+
    '    <embed src="WNFlvPlayer.swf" flashvars="file='+$altContent+'&autostart=true" allowfullscreen="true" width="720" height="480" name="flv" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />'+
    '  </object>'+
    '</div>'    
    ).fadeIn(2000);