title: How to make sound play only on current page? Java Script
body: <p>I am a graphic designer building website in Cargo Collective. I want to make sound play when user clicks the mouse or tap the screen. I use this code:</p>
  <pre><code>&lt;script&gt;
  function MouseSound() {
      var fileUrl = &quot;https://files.cargocollective.com/c1242413/sound-1.mp3&quot;;
      var audio = new Audio(fileUrl);
      audio.play();
  }
  
  window.addEventListener('click', MouseSound , false);
  &lt;/script&gt;
  </code></pre>
  <p>I use function MouseSound() to do it. But I have a problem — the sound keeps playing on the next website page on click, even if there's no script in it. I want to play sound only on pages with the script.</p>
  <p>I guess it's because <code>window</code> thing? Or it's script just stays in cache? How it's possible to play different sounds on different pages OR just play them only on pages, that have the script? Thank you.</p>