Javascript examples for Browser Object Model:Window setTimeout
Run a function by a specified number of times with setTimeout(fn(), time)
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> var foo = function() {//from ww w . j av a2s. c o m console.log(new Date().getTime()); }; (function(count) { if (count < 5) { foo(); var caller = arguments.callee; window.setTimeout(function() { caller(count + 1); }, 1000); } })(0); </script> </head> <body> </body> </html>