Sound script for all browsers
I use this script for all of my games. This will add sound functionality for all browsers. IE will use .mp3 sound files and all others will use .wav files. You will need to create a wav and mp3 version of each sound file. It has be ability to mute the sound if the user does not want it.

There are 3 functions used in this script:
  • AddSound("sound name","sound file name without extension","autoplay"(optional),"loop"(optional));
  • PlaySound("sound name");
  • PauseSound("sound name");

    You must Add a sound before you can play it. There are alerts if you try to play or pause a sound when you have not added it. You must declare the HTML coding has HTML5. You do this with the <!DOCTYPE html> tag at the beginning of your page.

    Put the script source where you want the Mute button to appear. Use the 3 functions somewhere after the script appears or use a onload function in the body tag to load the sounds (AddSound).

    This is the mute button created by the script: The mute button images are yessound.gif and nosound.gif.

    Play unnatural sound
    nature sound

    Update: Fixed bug with IE.

    Here is the code for the sound.js: