Eddie Domingues Eddie Domingues - 2 years ago 131
HTML Question

How to play an external audio file with javascript not Jquery?

Does anyone know how to play sounds with JavaScript, for example I want to play this sound


Answer Source

Start by defining your audio file.

Then you can call it where you want in your scripts with play().

var myAudio = new Audio('sounds/main.mp3');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download