944,081 Members | Top Members by Rank

Ad:
Jan 7th, 2005
0

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

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
odee is offline Offline
27 posts
since Dec 2004
Aug 31st, 2006
0

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

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";
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Sep 1st, 2006
0

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

<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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hari123 is offline Offline
1 posts
since Aug 2006
Sep 1st, 2006
0

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

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".
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Mar 16th, 2011
0
Re: how to change the the value of src in <embed> using javascript
There is a solution:

var oEmbed = document.getElementById("myMidi");
oEmbed.setAttribute("src", "newfile.mid")
Reputation Points: 6
Solved Threads: 3
Newbie Poster
Voynex is offline Offline
15 posts
since Jul 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Update database from dynamic table
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: moving in javascript





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC