Running scripts ciclically


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <html>
  2. <body>
  3.  
  4. <input type="text" id="clock" />
  5. <script language=javascript>
  6. var int=self.setInterval("clock()",1000);
  7. function clock()
  8. {
  9. var d=new Date();
  10. var t=d.toLocaleTimeString();
  11. document.getElementById("clock").value=t;
  12. }
  13. </script>
  14. </form>
  15. <button onclick="int=window.clearInterval(int)">Stop</button>
  16.  
  17. </body>
  18. </html>

URL: http://www.w3schools.com/jsref/met_win_setinterval.asp

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.