Example prevent close modal when click outside modal SweetAlert

closeOnClickOutside : Decide whether the user should be able to dismiss the modal by clicking outside of it, or not.

Default: closeOnClickOutside: true

Example:

 

<!DOCTYPE html>

<html>

    <body>

        <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

        <p>Example Alert use closeOnClickOutside</p>

 

        <button onclick="run()">Run</button>

        <script>

            function run() {

             swal("Can't close modal when click outside modal",{

                closeOnClickOutside: false,

              });

            }

        </script>

    </body>

</html>

 

Result:

 

 

Now you click outside modal can't close