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 回答