advapi
advapi

Reputation: 3907

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

Upvotes: 0

Views: 5334

Answers (3)

Matthis
Matthis

Reputation: 31

According to https://github.com/sweetalert2/sweetalert2/releases/tag/v11.0.0 you should use v.10.16.7 for old browser support

Upvotes: 1

Thamer
Thamer

Reputation: 1954

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

Upvotes: 1

Alexandre Datain
Alexandre Datain

Reputation: 34

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

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

Upvotes: 1

Related Questions