I have the following scenario..
When the user visit my website I show the user some audio files from the server. When the user clicks on one link, then the jquery function is eventually executed and change the source of the embedded object to selected file.
my script is :
<script type="text/javascript">
$("#song").click(function(){
var src=$(this).attr("href");
var plyr=document.getElementById("mplayer");
var clone=plyr.cloneNode(true);
clone.setAttribute('src',src);
plyr.parentNode.replaceChild(clone,plyr)
});
</script>
Link to select audio file.
<a href="resources/songs/xx21.mp3" id="song">
xx21
And the object is
<div id="music">
<embed type="audio/mpeg" src="#" name="plugin" height="100%" width="100%" id="mplayer">
</div>
What happening for me is, When I click on the link. The song plays in new page. I need to play the song with embedded object inside the div music.