suppose 30 min objective type online exam.
once user login and click on start exam timer start.
but if user close tab and re-open tab then this timer start again.
how can i prevent to do !
i.e user has last 10 min left and he refress page or close tab and reopen that tab
how i manage time. that it will not start from 30 min again.
i see some countdown timer but when i refress page it's start again from full time.
What I have tried:
var timer2 = "30:00";
var interval = setInterval(function () {
var timer = timer2.split(':');
//by parsing integer, I avoid all extra string processing
var minutes = parseInt(timer[0], 10);
var seconds = parseInt(timer[1], 10);
--seconds;
minutes = (seconds < 0) ? --minutes : minutes;
if (minutes < 0) clearInterval(interval);
seconds = (seconds < 0) ? 59 : seconds;
seconds = (seconds < 10) ? '0' + seconds : seconds;
//minutes = (minutes < 10) ? minutes : minutes;
$('.countdown').html(minutes + ':' + seconds);
timer2 = minutes + ':' + seconds;
if(minutes == 0 && seconds == 0)
{
alert('Exam Finished');
window.location.href = "/home/FirstQuestion";
}
}, 1000);