Firefox6中警告框无法阻止请求
为了防止双击提交按钮,我编写了以下函数,该函数在表单的 onsubmit
事件上调用。
<script language="JavaScript">
var submitFlag = false;
function checkForm(){
if ( submitFlag == false ) {
submitFlag = true;
return true;
} else {
alert('double click');
return false;
}
}
</script>
<form name="f1" method="post" action="B.jsp" onSubmit="return checkForm()">
在 Internet Explorer 中,当我单击提交按钮两次时,会出现警报方法。如果我不单击警告框中的“确定”按钮,则 jsp 不会重定向。
然而,在 Firefox6 中,警告框非常快,我没有时间单击“确定”按钮。 jsp重定向得很快,第二个请求已经发出去了。
如何阻止该请求在 Firefox 中通过?
For preventing the submit button's double click, I wrote the following function which is called on the form's onsubmit
event.
<script language="JavaScript">
var submitFlag = false;
function checkForm(){
if ( submitFlag == false ) {
submitFlag = true;
return true;
} else {
alert('double click');
return false;
}
}
</script>
<form name="f1" method="post" action="B.jsp" onSubmit="return checkForm()">
In Internet Explorer, when I click the submit button twice the alert method occurs. If I don't click the okay button in the alert box, the jsp is not redirected.
However in Firefox6 the alert box is very fast and I have no time to click the ok button. The jsp is redirected very fast and the second request has been sent out.
How can I block the request from going through in Firefox?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以禁用该按钮。
从FFx4(Gecko 2)开始,他们重新设计了盒子系统,所以它不再是一个真正的警报/提示/确认盒子,这是为了用户的安全,所以没有滥用盒子。
You could disable the button.
Since FFx4 (Gecko 2) they redone the boxes system, so it is no longer an actual alert/prompt/confirm box, this was done for security of the user, so there's no abuse of the boxes.