Advertisement
lalatino

javascript timeout - example

Jul 11th, 2012
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title> http://stackoverflow.com/questions/11439499/how-to-call-a-javascript-function-every-second-in-html/ </title>
  5. <script type="text/javascript">
  6. <!--
  7. function CountdownAnzeigen(countdown){
  8.     document.getElementById('countdown').innerHTML = countdown--;
  9.     if (countdown>0) {
  10.        window.setTimeout(function(){window.CountdownAnzeigen(countdown);}, 1000);
  11.     } else { alert('The End');}
  12. }
  13. //-->
  14. </script>
  15. </head>
  16. <body>
  17. <input type="button" value="count down" onclick="window.CountdownAnzeigen(10)"/>
  18. <div id="countdown"></div>
  19. </body>
  20. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement