Including sound in the web page using JavaScript


You can include the sound in web page using JavaScript.  But this code will work only on Netscape browser. I am giving the small example, how the sound works on the hyperlink of the web page.



Add the following code in the <HEAD> section of the page.

<SCRIPT LANGUAGE=JavaScript>
<!-- Hide from old browsers

  function Play_Sound(){
    document.sound2.play();
}
// -->
</SCRIPT>

add the following code in the <BODY> tag of the HTML page.

<EMBED src="YOUR SOUND FILE" autostart=false HIDDEN=TRUE NAME="sound2" MASTERSOUND>
<A href="http://www.yourwebsitename.com" onMouseOver="Pay_Sound()" onClick="return false;">
Sound on the HTML Page</A>



Added on December 28, 2007 Comment
}