Search code examples
sweetalert2

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

enter image description here enter image description here

Thanks


Solution

  • https://github.com/t4t5/sweetalert/issues/69

    on the cdn you ask for an older version without this commit