How to make beep sound in JavaScript - javatpoint

PHOTO EMBED

Tue Feb 22 2022 11:26:06 GMT+0000 (Coordinated Universal Time)

Saved by @sarthi

<html>   
<head>   
    <title> Beep sound on button click </title>   
</head>   
  
<body>   
    <center>  
    <h2 style="color:brown"> Example: Beep a sound </h2>  
    <h4> Press the Button to beep a sound </h4>   
  
    <!-- Use embed to provide the link of beep sound from internet -->  
    <embed src="https://www.soundjay.com/button/sounds/beep-01a.mp3" autostart="false" width="0" height="0" id="sound1"  
enablejavascript="true">  
    <button onclick="playSound('sound1')"> Click to beep </button>   
  
    <script>   
           //user-defined function to play a beep sound  
    function playSound(beepSound) {   
  
            //get the sound in JavaScript variable and play it  
        var audio = document.getElementById(beepSound);   
        audio.play() ;  
    }   
    </script>   
    </center>  
</body>   
</html>  
content_copyCOPY

https://www.javatpoint.com/how-to-make-beep-sound-in-javascript