Intenta crear una página html limpia y pruébalo así:
swal({ title: "Are you sure?", text: "Once deleted, you will not be able to recover this imaginary file!", icon: "warning", buttons: true, dangerMode: true, }) <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>Probablemente el problema sea con otras secuencias de comandos en su página, ya que su código debería funcionar, en su lugar, puede intentar usar Sweetalert2 de esta manera:
Swal.fire({ title: 'Do you want to save the changes?', showCancelButton: true, confirmButtonText: 'CONFIRM', denyButtonText: `CANCEL`, }).then((result) => { /* Read more about isConfirmed, isDenied below */ if (result.isConfirmed) { // confirm button pressed console.log("confirm") } else if (result.isDismissed) { // deny button pressed console.log("deny") } }) <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.1.9/dist/sweetalert2.all.min.js"></script>EDITAR:
Intente agregar jquery en su página HTML antes de importar otras secuencias de comandos como esta:
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>aquí está la respuesta
swal({ title: "Are you sure?", text: "Once deleted, you will not be able to recover this imaginary file!", type: "warning", showCancelButton: true, confirmButtonColor: '#DD6B55', confirmButtonText: 'Yes', cancelButtonText: "No", closeOnConfirm: false, closeOnCancel: false },O
swal({ text: "Once deleted, you will not be able to recover this imaginary file!", buttons: ["Yes", "No"], });o
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script> swal("Are you sure you want to do this?", { buttons: ["Yes", "No"], });