Javascript examples for Browser Object Model:Window setTimeout
Recursive function call inside setTimeout()
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//w w w .j av a 2s. c om var i = 0; (function repeat(){ if (i++ > 5) return; setTimeout(function(){ document.write("Iteration" + i + "<br />"); repeat(); }, 5000); })(); } </script> </head> <body> </body> </html>