Auto Refresh Your Page
Submitted by alpha_luna on Monday, May 23, 2016 - 11:47.
If you are looking for a source code to have an Auto Refresh function to your projects then you are at the right place. There are many sites that have this function to refresh their page automatically. So, let's work on it.
Full Script
Source Code:
This script that you can edit the refreshing time of your page.- //enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
- var limit="0:30"
- <script>
- //enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
- var limit="0:30"
- var doctitle = document.title
- var parselimit=limit.split(":")
- parselimit=parselimit[0]*60+parselimit[1]*1
- function startTo_Refresh(){
- if (parselimit==1)
- window.location.reload()
- else{
- parselimit-=1
- curmin=Math.floor(parselimit/60)
- cursec=parselimit%60
- if (curmin!=0)
- curtime=curmin+" minutes and "+cursec+" seconds left until your page refresh!"
- else
- curtime=cursec+" seconds left until your page refresh!"
- document.title = doctitle + ' (' + curtime +')'
- setTimeout("startTo_Refresh()",1000)
- }
- }
- if (window.addEventListener)
- window.addEventListener("load", startTo_Refresh, false)
- else if (window.attachEvent)
- window.attachEvent("load", startTo_Refresh)
- </script>
Output:
As you can see the image below. We set the refreshing time in "0:30" seconds. And, that's it!!! You can insert this script to have auto refresh on your page. So what can you say about this work? Share your thoughts in the comment section below or email me at [email protected]. Practice Coding. Thank you very much.Add new comment
- 141 views