bora89
1/23/2017 - 4:44 PM

From http://stackoverflow.com/questions/10105063/how-to-play-a-notification-sound-on-websites

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

    <head>
        <title>Audio test</title>

        <script type="text/javascript">
            /**
             * @param {string} filename The name of the file WITHOUT ending
             */
            function playSound(filename){   
                document.getElementById("sound").innerHTML='<audio autoplay="autoplay"><source src="' + filename + '.mp3" type="audio/mpeg" /><source src="' + filename + '.ogg" type="audio/ogg" /><embed hidden="true" autostart="true" loop="false" src="' + filename +'.mp3" /></audio>';
            }

        </script>
    </head>

    <body>

        <!-- Will try to play bing.mp3 or bing.ogg (depends on browser compatibility) -->
        <button onclick="playSound('bing');">Play</button>  
        <div id="sound"></div>

    </body>
</html>