Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation how do you change the src value in the embed command and show it instantly?

    i have been fighting with this for days now and i cannot figure out how to change a diplaying flash file on a page with a link or a button. i can display the flash file with the <embed src="flash.swf" name="flashdisplay"> but i cannot get the src to change like the Image Flip in Javascript.

    when the user clicks on "Next", the displaying flash file will change to a different one that is already uploaded to the server....without refreshing the page

    Can some one help!

  • #2
    New Coder
    Join Date
    Oct 2005
    Posts
    87
    Thanks
    1
    Thanked 0 Times in 0 Posts
    You could place a <span> tag around the embed tag. Then just create an image or button that includes an onclick event and create a function that will change the innerHTML of the span tag.

    If that doesn't work you could try using the getelementbyid command and setting the src to a different file. You may have to refresh though for this option to work.

    Code:
    //option 1
    function changeEmbed() {
    document.getElementById('flash').innerHTML = "<embed src='newfile.swf' name='newfile'></embed>";
    }
    
    <span id="flash">
    <embed name="original.swf" name="original">
    </embed>
    </span>
    
    <img src="next.gif" onclick="changeEmbed()">
    
    
    //option 2
    document.getElementById('oldfile').setAttribute('src','newfile.swf');
    
    <embed src="oldfile.swf" name="oldfile" id="oldfile"></embed>

  • #3
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Thanks!

    I got it to work by using IFrames and the getelementid thing.

  • #4
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I want to do something similar

    except the src is an mp3 file in the <embed></embed>..... I try to change the src using
    getElementById('name').src="name.mp3" and then using onclick="functionname()" but I always get an error...

    I also tried using .innerHTML="" to change the html in my <div></div> but I keep getting the following error:

    Error: Unterminated string constant

    I made sure that the html within the .innerHTML="" does not have an " in it and if its needed I replace " with '. So can anyone u tell me whats wrong?

  • #5
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is the javascript code:

    function Scar()
    {
    document.getElementById('embed1').innerHTML="<embed src='http://apollo.bluelaguna.net/ccmusic//01%20-%20Chrono%20Cross%20~%20Time's%20Scar.mp3'
    width='140' height='40' autostart='true' loop='TRUE'>
    </embed>"
    }

    Here is the onclick and <div>:

    <p onclick="Scar()">Scar</p>
    <div id="embed1"><embed src="http://www.ocremix.org/songs/Chrono_Trigger_Far_Away_Memories_OC_ReMix.mp3" width="140" height="40" autostart="true" loop="true">
    </embed> <br>
    <font size=1>You are listening to "Far Away Memories" remix from www.ocremix.org . You have the option to turn the music off at any time.</font>
    </div>
    Last edited by samuisamu; 12-06-2005 at 04:46 AM.

  • #6
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Search in the multimedia forum for a thread titled Embedded Windows Media Player you will find a thread that has a discussion on exactly what you are trying to do.


  •  

    Posting Permissions

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