'Sweetalert not working on IE 11, works on FireFox, Chrome
I've got a really strange problem with Sweetalert2 when I try to execute it from IE I got nothing showed. I've read on the site SA site to add the polyfill but it doesn't solve the problem.
The strange thing is that if I try the sweealert demo site it works. When I try to invoke from the IE's console the swal('ok') I got the following output that seems to be the class content instead of the exection
Here's my code(I re-defined the alert)
<script type="text/javascript">
alert = function (msg, title, type) {
if (type == null)
type = 'error';
if (title == null)
title = 'Attenzione';
swal({
title: title,
text: msg,
type: type,
confirmButtonText: 'Ok'
});
}
function ShowToastr(message) {
swal({
position: 'top-end',
type: 'success',
title: message ? message : 'Operazione completata con successo',
showConfirmButton: false,
timer: 1500
});
}
</script>
Inside the _Layout.cshtml I've in the head section
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.all.min.js"></script>
<!-- Include a polyfill for ES6 Promises (optional) for IE11, UC Browser and Android browser support -->
<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.js"></script>
And here's what I see when I try to run it from console
Thanks
Solution 1:[1]
https://github.com/t4t5/sweetalert/issues/69
on the cdn you ask for an older version without this commit
Solution 2:[2]
you are trying to update sweetAlert configuration. to do that, you should use mixin
like this :
const toast = swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000
});
toast({
type: 'success',
title: 'Signed in successfully'
})
check the documention link please for more details : sweetalert configuration
Solution 3:[3]
According to https://github.com/sweetalert2/sweetalert2/releases/tag/v11.0.0 you should use v.10.16.7 for old browser support
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 | Alexandre Datain |
Solution 2 | |
Solution 3 | Matthis |