Open page by clicking Ok - Sweetalert

Asked

Viewed 1,596 times

3

I’m doing a test with the plugin SweetAlert, and would like to open a page by clicking on ok, but I couldn’t do.

I ran a test using setTimeout, but she got a lot of wind...

<html>
    <head>
        <script src="sweet/dist/sweetalert.min.js"></script>
        <link rel="stylesheet" type="text/css" href="sweet/dist/sweetalert.css">
    </head>
    <body>
        <script>
            swal("Sucesso!", "TAG nº<? print($ordem); ?> editada.", "success");
            setTimeout(function() {
                window.location = '/manutencao/EditarTag.php';
            }, 2000);
        </script>
    </body>
</html>

1 answer

5


According to the documentation you can use an object followed by the function to be executed when the button is pressed. It could be something like this:

swal({
    title: "Sucesso!",
    text: "TAG nº<? print($ordem); ?> editada.",
    type: "success",
    closeOnConfirm: false // ou mesmo sem isto
}, function() {
    window.location = 'http://wikipedia.com';
});

jsFiddle: http://jsfiddle.net/ncyz6tn3/

  • 1

    That’s right Sergio. Thanks for the documentation, I hadn’t seen.

  • 1

    @Diego is welcome. jsFiddle can not use window.location because they block, but it gets the link.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.