предупреждение со звуковым JavaScript
if (x > 10) {
var snd = new Audio('/alarm.mp3');
snd.play();
alert("Thank you!");
}
Tired Thrush
if (x > 10) {
var snd = new Audio('/alarm.mp3');
snd.play();
alert("Thank you!");
}
<!DOCTYPE html>
<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>
<button onclick="play()">Press Here!</button>
<script>
function play() {
var audio = new Audio(
'https://media.geeksforgeeks.org/wp-content/uploads/20190531135120/beep.mp3');
audio.play();
}
</script>
</body>
</html>
<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>