'Implement sound in sweetalert popup
English is not my mother tongue, please excuse any errors on my part.
Is it possible to implement an audio file in swalfire popup. I would have an notification/sound during this popup:
Swal.fire({
title: 'Custom width, padding, background.',
width: 600,
padding: '3em',
background: '#fff url(/images/trees.png)',
backdrop: `
rgba(0,0,123,0.4)
url("/images/nyan-cat.gif")
left top
no-repeat
`
})
Solution 1:[1]
This worked for me
var soundfile = "sounds/RedAlert.mp3";
Swal.fire({
title: 'Your Title!',
html: 'Text or Content',
confirmButtonClass: 'btn btn-primary',
confirmButtonText: 'Your Text',
buttonsStyling: false,
onOpen: function () {
var audplay = new Audio(soundfile)
audplay.play();
}
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ram Amancha |