I have a script where user can edit their content in a period of time, so I added this time counter:
function StartCountDown(myDiv,myTargetDate)
{
var dthen = new Date(myTargetDate);
var dnow = new Date("<?php echo $targetdate ?>");
ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountBack(myDiv,gsecs);
}
function Calcage(secs, num1, num2)
{
s = ((Math.floor(secs/num1))%num2).toString();
if (s.length < 2)
{
s = "0" + s;
}
return (s);
}
function CountBack(myDiv, secs)
{
var DisplayStr;
var DisplayFormat = "%%D%% %%H%%:%%M%%:%%S%%";
if(secs>86400)
{
DisplayStr = DisplayFormat.replace(/%%D%%/g, Calcage(secs,86400,100000)+' Days');
}
else
{
DisplayStr = DisplayFormat.replace(/%%D%%/g,"");
}
if(secs>3600)
{
DisplayStr = DisplayStr.replace(/%%H%%/g, Calcage(secs,3600,24));
}
else
{
DisplayStr = DisplayFormat.replace(/%%D%% %%H%%/g,"00");
}
DisplayStr = DisplayStr.replace(/%%M%%/g, Calcage(secs,60,60));
DisplayStr = DisplayStr.replace(/%%S%%/g, Calcage(secs,1,60));
if(secs > 0)
{
document.getElementById(myDiv).innerHTML = DisplayStr;
setTimeout("CountBack('" + myDiv + "'," + (secs-1) + ");", 990);
}
else
{
document.getElementById(myDiv).innerHTML = "Period Over";
}
}
the counter is working fine, and counts the time remaining, but if the user didn’t leave the page and the time remaining reached the 0 he will get this message (Period Over), and he will be able to edit his content.
what I’m looking for is a code instead of (Period Over) makes the pager reloaded or refreshed when the counter reached the targeted time.
thanks,
If I understood you correctly, you are hitting the ‘Period Over’ text OK, so just replace that line with: