0

need help here. how can i change the src in <embed> using javascript that works in firefox?

ex.

<embed src="music.mid">

- how can i change "music.mid" to another midi file.

6
Contributors
6
Replies
11
Views
12 Years
Discussion Span
Last Post by Taywin
0

First, I don't work much with embeds, so this is speculation. But you need to give your element an ID, as such:

<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:

document.getElementById("myMidi").src = "newfile.mid";
0

<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.

0

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".

0

There is a solution:

var oEmbed = document.getElementById("myMidi");
oEmbed.setAttribute("src", "newfile.mid")

0

anyone know how to make that part where you said "newfile.mid" be a variable as well? i mean something like

function myFunction(variable) {
object = element.setAttribute("src", variable); 
object.Play();
}

html: 

<font size="5" onclick="myFunction('filepath/file.ext');">text1</font>
<font size="5" onclick="myFunction('filepath/file2.ext');">text2</font>
etc....

<embed src="" ></embed>

would this work?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.