<div class="codetitle"> <span><a style="CURSOR: pointer" data="402" class="copybut" id="copybut402" onclick="doCopy('code402')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code402"> <br>pageEncoding="UTF-8"%> <br> <br> <br> <br> <br><title>一定时间内,只能发送一次请求</title> <br><script type="text/javascript" src="%24%7BpageContext.request.contextPath%7D/editor/jquery/jquery-1.4.4.min.js"></script> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <br><script language="JavaScript"> <BR>var maxtime = 10;//设置至少10才能发送一次请求 <BR>function test(obj){ <BR>if(obj.value=='提交'){ <BR>check(); <BR>btn = setInterval("CountDown()",1000); <BR>}else{ <BR>alert("一分钟内只能发送一次!"); <BR>} <BR>} <BR>function CountDown(){ <BR>if(maxtime>=0){ <BR>seconds = Math.floor(maxtime%60); <BR>msg = "距离时间结束还有"+seconds+"秒"; <BR>$("#btn").val(msg); <BR>--maxtime; <BR>}else{ <BR>$("#btn").val("提交"); <BR>clearInterval(btn); <BR>maxtime = 10; <BR>} <BR>} <BR>function check(){ <BR>alert("哈哈,到我了!"); <BR>} <br><br></script> <br> <br> <br><input type="button" id="btn" value="提交" onclick="test(this)"> <br> <br> <br> </div>