Add new <embed> element to play mp3 file - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Embed

Description

Add new <embed> element to play mp3 file

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script language="javascript" type="text/javascript">
function Sound(surl) {//from  ww w . ja  va2s . com
console.log("working");
document.getElementById("myspan").innerHTML= "<embed src='http://your file.mp3' hidden='true' autostart='true' loop='false' />";
}

      </script> 
   </head> 
   <body> 
      <span id="myspan"></span> 
      <form> 
         <img src="http://www.java2s.com/style/download.png" onMouseOver="Sound('success.wav')"> 
      </form>   
   </body>
</html>

Related Tutorials