php - how to show confirm box when refresh in countdown timer -


have goog day , facing problem in 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 problem when click refresh, form not show here will submitted without alert , when time finish there alert box pop out, hope can confirm box yes,no let user choose,but cant make it,so can me? thanks

<script type="text/javascript">                              window.onbeforeunload= function() {                             var isok = confirm("are sure?");                             if(isok)                              {                             settimeout('document.myform.submit()',1);                             }                             }                              </script> 

but when click f5 refresh ,the box not show

just plain simple confirm box?

var isok = confirm("are sure?")

then can use isok see if should submit form:

if(isok)    document.myform.submit() 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -