Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript make alert sound

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
        content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
  
<body>
    <h1>Press the Button</h1>
  
    <audio id="chatAudio" >
        <source src=
"https://media.geeksforgeeks.org/wp-content/uploads/20190531135120/beep.mp3" 
        type="audio/mpeg">
    </audio>
    <button onclick="play()">Press Here!</button>
   
    <script>
        var audio = document.getElementById('chatAudio');
        function play(){
            audio.play()
        }
    </script>
</body>
</html>
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #javascript #alert #sound
ADD COMMENT
Topic
Name
7+4 =