关于javascript:重定向到alert box上的其他页面确认

Redirect to other page on alert box confirm

本问题已经有最佳答案,请猛点这里访问。

这是我的一项职能,其中有一个问题:

1
2
3
4
5
6
7
8
9
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。


试试这个:

1
2
3
4
5
6
7
8
9
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";

    }
}