将按钮链接到 SweetAlert 中的另一个页面

问题描述 投票:0回答:3

我使用的是 Sweet Alert,并且有 2 个按钮;一个是取消按钮,另一个是继续按钮。我想将“继续”按钮链接到另一个页面“Trial.php”。我该如何继续?下面是我尝试过的代码:

if(m <= 2){
  swal({
    title:"dataset file is: "+  ""+size2 +"Mb",
    text: "a cluster of 1 node will be required for processing",
    buttons: {
      cancel: true,
      confirm: "continue"
    }
  })

javascript html css function alert
3个回答
0
投票

使用

.then()
查看按下按钮的值,如果该值是“继续”,则使用
window.location.href
将用户重定向到另一个页面:

swal({
  title: "dataset file is: " + "" + size2 + "Mb",
  text: "a cluster of 1 node will be required for processing",
  buttons: {
    cancel: true,
    confirm: "continue"
  }
}).then((value) => {
  if (value === "continue") {
    window.location.href = "trial.php";
  }
});

0
投票

swal({ title: "test", text: "testing", buttons: { cancel: true, confirm: "continue" } }).then((value) => { if (value) { window.location.href = "trial.php"; } });


0
投票

斯瓦尔({ title: "您输入的数量少于要求的数量!", text: "您想增加这批货物的浪费吗?", 类型:“信息”, 显示取消按钮:真, 确认按钮颜色: "#1695B8", informButtonText: "是的,增加浪费", 关闭确认:假 }, 功能(){ var Waste_link = 'admin/Shipment_new/add_wastage'; window.location.href = Waste_link; //swal("已删除!", "你的虚拟文件已被删除。", "成功"); });

© www.soinside.com 2019 - 2024. All rights reserved.