Javascript examples for Browser Object Model:Window setInterval
Use setInterval function as thread in web page
<html> <head></head> <body onload="myFunction()"> <div id="num"> <div> <script> function myFunction()//from www .j a va 2 s . c o m { document.getElementById("num").innerHTML=1; setInterval(function() {document.getElementById("num").innerHTML=Number(document.getElementById("num").innerHTML)+1},1000); } </script> </div> </div> </body> </html>