Auto Refresh Page JS


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

Why do this?
===========
*hopefully* this will cause the page to refresh and provide a stop button in the future. The idea is to use it while developing in a text editor, as in Vim or its ilk, and not have to alt+tab all the _*flipping*_ time.

For right now its just straight from the source I got it. Additions will be made later.


Copy this code and paste it in your HTML
  1. <script>
  2. <!--
  3.  
  4. /*
  5. Auto Refresh Page with Time script
  6. By JavaScript Kit (javascriptkit.com)
  7. Over 200+ free scripts here!
  8. */
  9.  
  10. //enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
  11. var limit="0:30"
  12.  
  13. if (document.images){
  14. var parselimit=limit.split(":")
  15. parselimit=parselimit[0]*60+parselimit[1]*1
  16. }
  17. function beginrefresh(){
  18. if (!document.images)
  19. return
  20. if (parselimit==1)
  21. window.location.reload()
  22. else{
  23. parselimit-=1
  24. curmin=Math.floor(parselimit/60)
  25. cursec=parselimit%60
  26. if (curmin!=0)
  27. curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
  28. else
  29. curtime=cursec+" seconds left until page refresh!"
  30. window.status=curtime
  31. setTimeout("beginrefresh()",1000)
  32. }
  33. }
  34.  
  35. window.onload=beginrefresh
  36. //-->
  37. </script>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.