You can attach a sound file to an event simply by pointing the web browser to the sound
file (using location.href). However, unlike a background sound, this kind of link will
either ask what you want to do with the file, or pop up a player for the sound file. (If
it asks what you want to do, choose "Play from location" (or whatever option
sounds like that), as opposed to the "Save to disk" option) Once the player
opens, it stays open, which is unfortunate. There are ways around this using ActiveX,
however only Microsoft Internet Explorer supports ActiveX right now. In the meantime, if
you want to see what I mean...
The function that plays the sound is named playSound(), as you can see by viewing the
document source to this page.
Another way to make a sound play is to make that sound the page's background sound.
Then have a script reload the page in response to some event.