26

これは私の関数の一部であり、質問が含まれています。

function deletePost() {
    var ask = window.confirm("Are you sure you want to delete this post?");
    if (ask) {
        window.alert("This post was successfully deleted.");

        /* How to redirect to another page on confirm? */

    }
}

純粋なJavascriptが必要です。

4

1 に答える 1

32

これを試して:

function deletePost() {
    var ask = window.confirm("Are you sure you want to delete this post?");
    if (ask) {
        window.alert("This post was successfully deleted.");

        window.location.href = "window-location.html";

    }
}
于 2012-09-25T22:22:15.887 に答える