linklee,
 
 
 
<!DOCTYPE HTML>
<html>
<head>
  <title>Untitled</title>
</head>
<body>
<input id="go" name="" type="button" value="go" onclick="foo()">
<div id='show'></div>
<script>
function timer(num, sec, foo) {
     var a = 0;
     return function () {
         a || window.setTimeout(function () {
             a = 0
         }, 1000 * sec);
         a < num && foo();
         a++;
     }
 };
function foo()
{
   document.getElementById('show').innerHTML+='test '
}
foo = timer(2,3,foo)
</script>
</body>
</html>