dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Swapping swf using JS and html5

Hybrid View

  1. #1
    Join Date
    May 2012
    Posts
    2

    Question Swapping swf using JS and html5

    This one has me scrtaching my head.

    All I want to do is to display a swf file and then swap to another when a button is pressed.

    The following code displays the first annimation correctly but nothing happens when the button is pressed.

    This should be so simple , any help is appreciated.


    <html>
    <meta http-equiv="X-UA-Compatible" content="IE=9" />

    <script type="text/javascript">

    function Changeanimation(){
    document.getElementById("annimate").src="video2.swf";
    document.getElementById("annimate").Play();
    }
    </script>

    <embed id="annimate" name="annimate" src="video1.swf" style="width: 514px; height: 362px" / ><br>
    <input type="button" value="Change Picture" onClick="Changeanimation();">
    </html>

  2. #2
    Join Date
    May 2012
    Posts
    2

    Ok I worked it out. But why does it have to be like this?

    <html>
    <meta http-equiv="X-UA-Compatible" content="IE=9" />

    I had to wrap the <embed> code in a <div> tag
    Then has to use innerHTML to change the <embed> tag.

    Seems very strange considering the hidden attribute can be changed directly but this one can't.

    Anyone understand this?



    <script type="text/javascript">

    function Changeanimation(){
    tmp=eval('document.all.div_cont');
    tmp.innerHTML='<EMBED id="annimate" src="video2.swf" AUTOSTART=TRUE width=514; height=362></EMBED>';
    }
    </script>

    <div id="div_cont">
    <embed id="annimate" name="annimate" src="video1.swf" width=514; height=362 / ></div><br>
    <input type="button" value="Change Picture" onClick="Changeanimation();">
    </html>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles