Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 拒绝确认对话框时重定向_Javascript_Jquery_Forms_Redirect - Fatal编程技术网

Javascript 拒绝确认对话框时重定向

Javascript 拒绝确认对话框时重定向,javascript,jquery,forms,redirect,Javascript,Jquery,Forms,Redirect,我的任务是在用户确认的基础上提交发件人。如果用户确认,则提交表单。如果用户拒绝,则发件人将重定向到其他页面。我有一个jsp表单,如下所示- ..... <form id="stageUpdateForm" method="post"> </form> ...... 现在,如果用户拒绝从其停留在当前页面提交。但是如果用户拒绝,我想将页面重定向到其他url(例如-www.google.com)。我怎样才能做到这一点?您想试试这样的方法: if (decision

我的任务是在用户确认的基础上提交发件人。如果用户确认,则提交表单。如果用户拒绝,则发件人将重定向到其他页面。我有一个jsp表单,如下所示-

.....
   <form id="stageUpdateForm" method="post">
   </form>
......

现在,如果用户拒绝从其停留在当前页面提交。但是如果用户拒绝,我想将页面重定向到其他url(例如-www.google.com)。我怎样才能做到这一点?

您想试试这样的方法:

if (decision) {
    window.location = "http://whenever.wherever";
} else {
    // Returning false from a submit handler will prevent the submit action.
    return false;
}

您想尝试以下方法:

if (decision) {
    window.location = "http://whenever.wherever";
} else {
    // Returning false from a submit handler will prevent the submit action.
    return false;
}
你可以做:

$('#stageUpdateForm').submit(function () {
    var decision = confirm('Some data changed. Are you sure?');

    // if user deny then redirect 
    if (!decision) {
        $(location).attr('href', 'http://www.google.com');
    }

    // If user confirm, than it will return true and the form will be sumbited
    return decision;
});
你可以做:

$('#stageUpdateForm').submit(function () {
    var decision = confirm('Some data changed. Are you sure?');

    // if user deny then redirect 
    if (!decision) {
        $(location).attr('href', 'http://www.google.com');
    }

    // If user confirm, than it will return true and the form will be sumbited
    return decision;
});

如果用户确认,则提交表单。如果用户拒绝,则发件人被重定向到其他页面(如www.google.com)。好的,翻转代码块,然后-原则适用:)如果用户确认,则提交表单。如果用户拒绝,则发件人将被重定向到其他页面(如www.google.com)。好的,翻转代码块,然后-原则适用:)