简体   繁体   中英

How to close current tab using swal alert box

I am using swal alert box, I just need to close my current tab when the user clicks on ok button.

$(document).ready(function(){
    swal({
        title: "Are you sure ??",
        text: 'hii', 
        icon: "success",
        buttons: true,
        //dangerMode: true,
    })
    .then((willDelete) => {
      if (willDelete) {
        window.close();
      } else {
        window.close();
      }
    });
});

By using a customizing the confirm dialog from Docs You can use the following code below:

 Swal.fire({ title: "Error", text: "wrong user or password", type: "error", showCancelButton: false, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'OK' }).then((result) => { if (result.value) { window.close(); } }) 
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script> 

PEN: CLICK HERE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM