Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Timer not accurate


fredfletcher - 8:59 pm on Mar 5, 2012 (gmt 0)


Hi, I have a question about an automatic redirection timer. Is there a script that is more accurate than the one shown below?

I ask this, because the one I am presently using is not accurate at all. I can live with a 40-60 second difference, but in using FF 8.0.1, it won't kick in till about 2-5 minutes later.

I did search in the forums for quite a while, but did not find anything.

Here is my code:

[JS]

var limit="60:00"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function begintimer(){
if (!document.images)
return
if (parselimit==1)
window.top.location="redirection_page.htm"
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left"
else
curtime=cursec+" seconds left"
window.status=curtime
setTimeout("begintimer()",1000)
}

---

[HTML]

<body onLoad="begintimer()">


Thread source:: http://www.webmasterworld.com/javascript/4425239.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com