Playing sound on a button click I am new to javascript and want to make sure I am on the right track when playing a sound. Is there anything I should not be doing better or not be doing at all. Below is a simple function. 

&lt;script language="javascript" type="text/javascript"&gt;
  function playSound(soundfile) {
    if (navigator.userAgent.indexOf('Firefox') != -1) {
      document.getElementById("dummy").innerHTML = "&lt;embed src=\"" + soundfile + "\" hidden=\"true\" autostart=\"true\" loop=\"false\" type=\"application/x-mplayer2\" /&gt;";
    } else {
      document.getElementById("dummy").innerHTML = "&lt;embed src=\"" + soundfile + "\" hidden=\"true\" autostart=\"true\" loop=\"false\" /&gt;";
    }
  }
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;span id="dummy"&gt;&lt;/span&gt;

  &lt;a href="#" onclick="playSound('doorbell.wav');"&gt;Click here to hear a sound&lt;/a&gt;
&lt;/body&gt;


I am not sure whether I should be using the audio tag or not. I appreciate any feedback
Regarding the HTML:

script element

For JavaScript, you can simply use &lt;script&gt; without the type attribute:


  If the language is not that described by "text/javascript", then the type attribute must be present


The language attribute is obsolete:


  Authors should not specify a language attribute on a script element.


a element

I'd say a real button should be used here, not a link:


button element with button type: &lt;button type="button" onclick="…"&gt;Click here to hear a sound&lt;/button&gt;
input element with button type: &lt;input type="button" onclick="…" value="Click here to hear a sound" /&gt;