Playing sound when the button is pressed - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Embed

Description

Playing sound when the button is pressed

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script language="javascript">
function playIt()/*from w  ww .  j  a va 2 s.  com*/
{
   document.getElementById("embed").innerHTML="<embed src='play.mp3' autostart=true loop=false volume=100 hidden=true>";
   return true;
}

      </script> 
   </head> 
   <body> 
      <form action="" method="post"> 
         <button type="button" onclick="playIt()">play</button> 
         <div id="embed"></div> 
      </form>  
   </body>
</html>

Related Tutorials