function setCountDown ()
{
seconds--;
if (seconds < 0){
minutes--;
seconds = 59
}
if (minutes < 0){
hours--;
minutes = 59
}
if (hours < 0){
days--;
hours = 23
}
document.getElementById("remain").innerHTML = hours+" hours, "+minutes+" minutes, "+seconds+" seconds";
SD=window.setTimeout( "setCountDown()", 1000 );
if (minutes == '00' && seconds == '00') { seconds = "00"; window.clearTimeout(SD);
window.alert("Time is up. Press OK to continue."); // change timeout message as required
//window.location = "http://www.yourpage.com" // Add your redirect url
}
}
function doTimer()
{
if (!timer_is_on){
timer_is_on=1;
setCountDown ();
}
}
function stopCount()
{
clearTimeout(SD);
timer_is_on = 0;
}
the problem is the pause working on one page but when i click the next button the page will reload and the truth is the timer never pause. i was wondering how can i pause the timer?
If I understand you correctly you want to have the state the timer to persist on all the pages so that even if you reload the page the timer is paused or continues counting where it left off ?
If this is the case a solution would be to send a ajax query to the server, wait for that and then submit the form. Then when you load the new page you use PHP (You have it in your tags) to check the session and echo the right value. So you could save how far the timer was and resume where the user left off on the last page.
Have a look at PHP Sessions and Ajax with JQuery.
Hope I understood that correctly.