how to change the the value of src in <embed> using javascript

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Dec 2004
Posts: 27
Reputation: odee is an unknown quantity at this point 
Solved Threads: 0
odee odee is offline Offline
Light Poster

how to change the the value of src in <embed> using javascript

 
0
  #1
Jan 7th, 2005
need help here. how can i change the src in <embed> using javascript that works in firefox?

ex.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <embed src="music.mid">

- how can i change "music.mid" to another midi file.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: how to change the the value of src in <embed> using javascript

 
0
  #2
Aug 31st, 2006
First, I don't work much with embeds, so this is speculation. But you need to give your element an ID, as such:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <embed id="myMidi" src="music.mid">
Then, you can get to the object using document.getElementById("myMidi"). At that point, try simply changing the source:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. document.getElementById("myMidi").src = "newfile.mid";
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 1
Reputation: hari123 is an unknown quantity at this point 
Solved Threads: 0
hari123 hari123 is offline Offline
Newbie Poster

Re: how to change the the value of src in <embed> using javascript

 
0
  #3
Sep 1st, 2006
<embed id="myMidi" src="music.mid">
document.getElementById("myMidi").src = "newfile.mid";

Hi, I already use this case but the embed object c'not accept the src.
there is my problem.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: how to change the the value of src in <embed> using javascript

 
0
  #4
Sep 1st, 2006
The "embed" tag may not allow that. What you may have to do instead is place the tag into a div, and then use JavaScript to completely rewrite the contents of the div. Research ".innerHTML".
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC