Posted in Javascript onFebruary 28, 2014
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>一定时间内,只能发送一次请求</title> <script type="text/javascript" src="${pageContext.request.contextPath}/editor/jquery/jquery-1.4.4.min.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <SCRIPT LANGUAGE="JavaScript"> var maxtime = 10;//设置至少10才能发送一次请求 function test(obj){ if(obj.value=='提交'){ check(); btn = setInterval("CountDown()",1000); }else{ alert("一分钟内只能发送一次!"); } } function CountDown(){ if(maxtime>=0){ seconds = Math.floor(maxtime%60); msg = "距离时间结束还有"+seconds+"秒"; $("#btn").val(msg); --maxtime; }else{ $("#btn").val("提交"); clearInterval(btn); maxtime = 10; } } function check(){ alert("哈哈,到我了!"); } </SCRIPT> </head> <body> <input type="button" id="btn" value="提交" onclick="test(this)"/> </body> </html>
如何设置一定时间内只能发送一次请求
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@