웹 페이지에 Collate
개체를 사용할 수 있습니다.
function Collate(timeout) {
this.timeout = timeout || 1000;
}
Collate.prototype = {
time: 0,
idle: function() {
var t = new Date().getTime();
return (t - this.time > this.timeout && (this.time = t));
},
prefer: function(func) {
this.func = func;
clearTimeout(this.timer);
this.timer = setTimeout(func, this.timeout);
}
};
기능을 한 번 실행하고 다음 1 초 이내에 다시 실행하지 않으려는 경우. 폼을 여러 번 제출에서 사용자를 방지하려는 경우, 당신이처럼이 :
var timer = new Collate(3000); //3 seconds
button1.onclick = function() {
if(timer.idle()) {
button1.form.submit();
} else alert("Don't click too quickly!");
}
//or on the form tag
<script>var submitTimer = new Collate(3000);</script>
<form action="post" onsubmit="return submitTimer.idle();">
당신이 이벤트가 여러 번 화재 만이 화재 마지막에 반응 할 것으로 예상하는 경우
. 는 사용자가 입력을 완료 한 후 검색 할 경우, 당신이처럼이 :
var timer = new Collate(700); //0.7 seconds
textfield1.onkeyup = function() {
timer.prefer(function() {
autocomplete.search(textfield1.value);
});
};
이 처리하는 가장 좋은 방법은 이메일이 아닌 차단 및 거래되지 중 하나입니다 있는지 확인하는 것입니다. – Raynos