title: Javascript Audio Play on click
body: <p>I have a JavaScript code to play a sound on click.
  It works on Chrome but on Firefox it starts on load.</p>
  <p>Can anyone help?</p>
  <pre><code>&lt;script&gt;
  var audio = new Audio(&quot;http://music.ogg&quot;);
  
  audio.oncanplaythrough = function(){
  audio.play();
  }
  
  audio.loop = true;
  
  audio.onended = function(){
  audio.play();
  }
  
  &lt;/script&gt;
  
  &lt;input type=&quot;image&quot; src=&quot;http://button.png&quot; onclick=&quot;audio.play()&quot;&gt;
  </code></pre>