php 甜蜜警报2 -“confirmButtonText”按钮中的链接

k4aesqcs  于 2023-06-20  发布在  PHP
关注(0)|答案(5)|浏览(148)

我想知道我怎么能把一个链接的按钮,产生Sweet Alert 2confirmButtonText
我们的目标是,当你按下该按钮重定向到一个页面,从数据库中删除一个记录,直到现在,我有一个简单的链接(<a>)在一个简单的按钮,但我想添加这个小确认。
下面是代码:

按钮如下:

jv4diomz

jv4diomz1#

这会成功的!

confirmButtonText: '<a href="url">LINK</a>'
hc2pp10m

hc2pp10m2#

我所做的是在确认按钮上附加一个函数,使用window.href来跟踪链接:

Swal.fire({
   title: '<strong>Are you sure?</strong>',
   icon: 'warning',
   html:`You really can't go back after this, We can't retrieve it either!`,
   showCloseButton: true,
   showCancelButton: true,
   focusConfirm: false,
   reverseButtons: true,
   focusCancel: true,
   cancelButtonText:`Blue pill`,
   confirmButtonText:`Red pill`
 }).then((result) => {
   if (result.value) {
     window.location.href = `/real_world`
   }
 });
7uhlpewt

7uhlpewt3#

你可以在sweet alert2中使用promising

Swal.fire({
 title: 'Are you sure?',
 text: "You won't be able to revert this!",
 type: 'warning',
 showCancelButton: true,
 confirmButtonColor: '#3085d6',
 cancelButtonColor: '#d33',
 confirmButtonText: 'Yes, delete it!'
}).then((result) => {
  if (result.value) {
  Swal.fire(
   'Deleted!',
   'Your file has been deleted.',
   'success'
 )
}
})

更重要的是,检查:https://sweetalert2.github.io/

kxxlusnw

kxxlusnw4#

我想我已经太晚了,回答这个问题,但它可能会帮助其他寻找类似东西的人。

Swal.fire({
        title: '<strong>Check Redirect!!</strong>',
        icon: 'success',
        showConfirmButton: false,
        allowOutsideClick: false,
        footer:`<a class="btn btn-primary" href="https://www.google.com">OK</a>`
    });
ecr0jaav

ecr0jaav5#

使用window.open

Swal.fire({
  title: 'Are you sure?',
  text: "You won't be able to revert this!",
  icon: 'warning',
  showCancelButton: true,
  confirmButtonColor: '#3085d6',
  cancelButtonColor: '#d33',
  confirmButtonText: 'Yes, delete it!',
  cancelButtonText: 'No'
}).then((result) => {
  if (result.isConfirmed) {
     window.open("https://www.google.com.br");
  }
})

相关问题