Javascript examples for Browser Object Model:Window setTimeout
setTimeout and clearTimeout usage
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {//from ww w. j ava 2s. c o m var i=10; var countDwn; var dumping = document.getElementById('dump'); function theTime(){ if(i > 0){ i-=1; }else{ clearTimeout(countDwn); } dumping.innerHTML = i; countDwn = setTimeout(theTime,1000); } theTime(); }); </script> </head> <body> <p id="dump"></p> </body> </html>