0

此 javascript 用于在提交表单之前确认表单,但是如果他们确认为 true 或确认为 false,我不知道如何添加重定向链接:

Javascript

<script>
function cancelalert(){
return confirm("By clicking OK you are submitting the form.");
}
</script>

HTML

onclick="return cancelalert()"
4

1 回答 1

1

与其confirm直接返回结果,不如将其放入变量中并采取相应措施:

var confirmed = confirm("By clicking OK you are submitting the form.");

if(confirmed)
{
  return true; // will sumbit the form. Do a redirect on the server side
}

// not confirmed. Show an alert or something
于 2013-06-02T17:02:13.747 回答