Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > Dialog API

SweetAlert2

Scroll Prev Next More

SweetAlert2 is yet another replacement for Javascript alert() function. You can use it in any Javascript events. You can find more examples in SweetAlert2 documentation.

Examples

Example 1

 

Just a simple popup message.

 

Swal.fire('Any fool can use a computer');

 

Example 2

 

A title with a text under.

 

 

Swal.fire(
'The Internet?',
'That thing is still around?',
'question'
);

 

Example 3

 

A modal with a title, an error icon, a text, and a footer

 

Swal.fire({
 icon: 'error',
 title: 'Oops...',
 text: 'Something went wrong!',
 footer: '<a href="">Why do I have this issue?</a>'
})

sweetalert2

Example 4

 

A modal window with a long content inside:

 

 

Swal.fire({
 imageUrl: 'https://placeholder.pics/svg/300x1500'
 imageHeight: 1500,
 imageAlt: 'A tall image'
});

 

 

 

See also:

AJAX helper object -> submit()

Tri-part events: Asynchronous tasks

Dialog API