How to use javascript to swap swf in html?

I put swf in my html page, but I would like it to change to another swf when I clicked the button in html. I used swfobject.js to insert swf and I use a prototype to write javascript. I thought I could just do it

$('movie').value = 'swf/bhts.swf';
alert($('movie').value);

the value changed to swf / bhts.swf, but it still plays the original swf file ... this is the code I use to insert swf

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="530" height="298" id="flashcontent">
<param id="movie" name="movie" value="swf/trailer.swf" />
</object>

thank.

+3
source share
2 answers

Using swfObject:

<div id='flashContent'>
</div>

<script type='text/javascript'>    
    // Setup your initial flash 
    var so = new SwfObject(.....);
    so.write ('flashContent');

    // Some event handler
    someElement.onclick = function ()
    {
         // Load up the new SWF
         so = new swfObject(....);
         so.write('flashContent');
    }
</script>
+2
source

SWFObject? swfobject.embedSWF SWF HTML , , Flash- URL-.

SWF URL-, . ID Flash, -

var swf = getElementById("flash_id");
swf.LoadMovie(0, "http://example.com/newSwfUrl.swf");

, Flash- , 0 ( ). Flash-, Flash 8 .

0

Source: https://habr.com/ru/post/1699587/


All Articles