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