Tom
Tom

Reputation: 12998

jquery to change swf

I want to be able to change the swf file showing on a page using the code below (with the comment turned into real code)

Is this possible??

jquery:

$("div.360container > p").click( function() {
    // show different swf by changing the value of the first param and src of the embed
});

html:

<div class="mycontainer" style='padding:2px;'>

  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="650" height="350">
    <param name="movie" value="/mySwf.swf" />
    <param name="quality" value="high" />
    <param name="wmode" value="opaque" />
    <embed src="/mySwf.swf" quality="high" wmode="opaque" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="650" height="350"></embed>
  </object>

  <p>click to change...</p>
</div>

Upvotes: 0

Views: 1588

Answers (1)

Mr. TA
Mr. TA

Reputation: 5359

Most reliable way to do that would be to set innerHTML of the element to your HTML. So, using jquery:

$("div.360container > p").click( function() {
    // show different swf by changing the value of the first param and src of the embed
    $(".mycontainer").html("<object ....><param name='movie' value='" + movieUrl + "' />....");
});

Upvotes: 1

Related Questions