have a goog day , i am facing some problem in the countdown timer
<div style="font-weight: bold; float:right;" id="quiz-time-left"></div>
<script type="text/javascript">
window.onbeforeunload= function() {
setTimeout('document.myForm.submit()',1);
}
</script>
<script type="text/javascript">
var max_time = 10;
var c_seconds = 0;
var total_seconds =60*max_time;
max_time = parseInt(total_seconds/60);
c_seconds = parseInt(total_seconds%60);
document.getElementById("quiz-time-left").innerHTML='Time Left: ' + max_time + ' minutes ' + c_seconds + ' seconds';
function init(){
document.getElementById("quiz-time-left").innerHTML='Time Left: ' + max_time + ' minutes ' + c_seconds + ' seconds';
setTimeout("CheckTime()",999);
}
function CheckTime(){
document.getElementById("quiz-time-left").innerHTML='Time Left: ' + max_time + ' minutes ' + c_seconds + ' seconds' ;
if(total_seconds <=0){
alert("Time Up!"); setTimeout('document.myForm.submit()',1);
} else
{
total_seconds = total_seconds -1;
max_time = parseInt(total_seconds/60);
c_seconds = parseInt(total_seconds%60);
setTimeout("CheckTime()",999);
}
}
init();
</script>
now my problem is when i click refresh, the form which i do not show here will will be submitted without alert and when the time finish there is a alert box pop out, now actually i hope can get the confirm box with yes,no to let the user choose,but cant make it,so can somebody help me? thanks
<script type="text/javascript">
window.onbeforeunload= function() {
var isOk = confirm("Are you sure?");
if(isOk)
{
setTimeout('document.myForm.submit()',1);
}
}
</script>
but when i click F5 for refresh ,the box do not show