You can trigger audio that is loaded in <audio>
or <object>
tags in a couple of ways.
In HTML5-compatible browsers like Firefox, Chrome, IE9, and Safari this is accomplished like so:
<audio id="attack">
<source src="attack.wav">
</audio>
<audio id="heal">
<source src="heal.wav">
</audio>
<a href = "#" onclick="document.getElementById('attack').play()">Click to Attack</a>
<a href = "#" onclick="document.getElementById('heal').play()">Click to Heal</a>
The "#" link is just to make sure that you don't go to a new page. I recommend using WAV files for short sounds -- WAV is compatible with basically every browser, and as long as your total sound effects end up less than maybe 1MB you should be okay. Otherwise you'll have to include both an .OGG and .MP3 files for each sound effect inside the tag, like so:
<audio id='attack'>
<source src='attack.ogg'>
<source src='attack.mp3'>
</audio>
<audio id='heal'>
<source src='heal.ogg'>
<source src='heal.mp3'>
</audio>
<a href = "#" onclick="document.getElementById('attack').play()">Click to Attack</a>
<a href = "#" onclick="document.getElementById('heal').play()">Click to Heal</a>
If you want to get this to work on IE7 and IE8 then you'll need to fall back on the <object>
tag. There's a good example of that available in this article.