- 
                prevent countdown timer for being restartedover 9 years ago 
- 
          
          over 9 years ago You can see working example here: 
 http://plnkr.co/edit/73bcovfv8RzrIQIR95Ep
- 
          
          over 9 years ago thanks alot i will appreciate your effort its was very helpful for me 
- 
          
- 
          
          over 9 years ago According to your code you are initialising with total_seconds = 60*10 and after each refresh total_seconds is again set to constant value. 
 You should store your last counter value in localStorage and initialise total_seconds with that updated localStorage value.if(localStorage.getItem("total_seconds")){ var total_seconds = localStorage.getItem("total_seconds"); } else { var total_seconds = 60*10; } var minutes = parseInt(total_seconds/60); var seconds = parseInt(total_seconds%60); function countDownTimer(){ if(seconds < 10){ seconds= "0"+ seconds ; }if(minutes < 10){ minutes= "0"+ minutes ; } document.getElementById("quiz-time-left").innerHTML = "Time Left :"+minutes+"minutes"+seconds+"seconds"; if(total_seconds <= 0){ setTimeout("document.quiz.submit()",1); } else { total_seconds = total_seconds -1 ; minutes = parseInt(total_seconds/60); seconds = parseInt(total_seconds%60); localStorage.setItem("total_seconds",total_seconds) setTimeout("countDownTimer()",1000); } }
- 
          
- 
          
          over 9 years ago hi can you help me again? first your code is working very well but i had little problem is it that i'm using this code for online test and if you finish up before time is up and start an another test the timer will start from where the other test is submitted 
 can i clear the timer or destroy it as we do to the cookie
- 
          
- 
          
          over 9 years ago sorry it's not working !!! 
- 
          
 
                      
                      
                      
    
    
 
               
               

5 Answer(s)