Where The Streets Have No Name

Delaying JavaScript Execution 본문

Developement/Web

Delaying JavaScript Execution

highheat 2008. 10. 29. 09:15
출처 : http://www.matts411.com/post/delaying_javascript_event_execution/

var onFooEndFunc = function() {
var delay = 50; /* milliseconds - vary as desired */
var executionTimer;

return function() {
if (executionTimer) {
clearTimeout(executionTimer);
}

executionTimer = setTimeout(function() {
// YOUR CODE HERE
}, delay);
};
}();