简体   繁体   English

如何在我的网站中使用Sweet Alerts。

[英]How to use Sweet Alerts in my website..?

I use "Sweetalerts" in my page. 我在页面中使用“ Sweetalerts”。 I've a static link which should redirect to "google.com". 我有一个静态链接,该链接应重定向到“ google.com”。 When i click on the link it shall show an alert message stating 当我单击链接时,它将显示一条警告消息,指出

if you click OK you will be redirected to google.com 如果单击确定,您将被重定向到google.com。

As soon as one hits "OK" the redirection takes place. 一旦点击“ OK”,就会发生重定向。

The problem is that I'm able to see the alert message while clicking on the link, but the button doesn't work. 问题是单击链接时我可以看到警报消息,但是该按钮不起作用。 It just closes the alert message instead of redirecting to the appropriated link. 它只是关闭警报消息,而不是重定向到适当的链接。

Have you tried the callback function of swal? 您是否尝试过swal的回调函数? Something like 就像是

swal({   
   title: "Are you sure?",   
   text: "If you click OK you will be redirected to google.com",   
   type: "warning",   
   showCancelButton: true,   
   confirmButtonColor: "#DD6B55",   
   confirmButtonText: "OK",   
   closeOnConfirm: true}, 
   function(){ 
        window.location.href = "www.google.com"; 
   });

If you post Code snippet, it will help other users to understand the issue. 如果您发布代码段,它将帮助其他用户理解该问题。

  swal({ 
  title: "Alert",
   text: "Redirecting to google",
    type: "success" 
  },
  function(){
    window.location.href = 'www.google.com';
});

Swal Alert has an option for callback functions that run after an action. Swal Alert具有在操作后运行的回调函数的选项。

swal({   title: "Are you sure?" },
     function(){  window.location.href = "www.google.com";  });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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