I’m using the exactly code of SweetAlert2 examples page:
JavaScript
x
18
18
1
swal({
2
title: 'Are you sure?',
3
text: "You won't be able to revert this!",
4
type: 'warning',
5
showCancelButton: true,
6
confirmButtonColor: '#3085d6',
7
cancelButtonColor: '#d33',
8
confirmButtonText: 'Yes, delete it!'
9
}).then((result) => {
10
if (result.value) {
11
swal(
12
'Deleted!',
13
'Your file has been deleted.',
14
'success'
15
)
16
}
17
})
18
Works fine on Firefox and Chrome, but Internet Explorer shows SCRIPT1002: Syntax Error
and not run the script…IE flag this portion as syntax error:
JavaScript
1
2
1
}).then((result) => {
2
Thanks for any help
Advertisement
Answer
(result) => {}
is an arrow function which is completely unsupported in IE. To fix this you’ll have to use a traditional anonymous function:
JavaScript
1
8
1
swal({
2
// options...
3
}).then(function(result) {
4
if (result.value) {
5
swal('Deleted!', 'Your file has been deleted.', 'success');
6
}
7
});
8