相当于 Response.Redirect(Request.RawUrl); jQuery JS 代码 防止表单多次提交

2010年8月27日 | JS功能代码 | Tags jQuery   | Views

//jQuery
方法一:
<script type="text/javascript">
$("input:submit").each(function() {
var srcclick = $(this).attr("onclick");
if(typeof(srcclick)=="function"){
$(this).click(function() {
if (srcclick()) {
setdisabled(this);
return true;
}
return false;
});}
});
function setdisabled(obj) {
setTimeout(function() { obj.disabled = true; }, 100);
}
</script>
方法一:
function disableOtherSubmit()
{
$("input:submit").each(function(i) {
setTimeout(function() { $("input:submit").eq(i).attr("disabled","true"); }, 100); });
}
//ASP.NET
Button_All.Attributes.Add("onclick", "this.disabled=true;" + this.ClientScript.GetPostBackEventReference(Button_All, ""));
Button_CurrentCount.Attributes.Add("onclick", "this.disabled=true;" + this.ClientScript.GetPostBackEventReference(Button_CurrentCount, ""));
Button_Between.Attributes.Add("onclick", "this.disabled=true;" + this.ClientScript.GetPostBackEventReference(Button_Between, ""));

提醒一下 本人没有试过,不会.net 哈哈

看了这篇文章如果对您有帮助,请点评一下吧(我会回访的∧_∧)。您的鼓励让我更努力!

 

相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。