0
有一個goog一天,我面臨的一些問題,在倒計時如何顯示確認對話框時刷新在倒數計時器
<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>
我現在的問題是,當我點擊刷新,形式,我不顯示這裏會提交沒有警報,當時間完成後有一個警告框彈出,現在其實我希望可以得到確認框是,不讓用戶選擇,但無法做到,所以有人可以幫助我嗎? 感謝
<script type="text/javascript">
window.onbeforeunload= function() {
var isOk = confirm("Are you sure?");
if(isOk)
{
setTimeout('document.myForm.submit()',1);
}
}
</script>
但是當我點擊F5進行刷新,該對話框不顯示
可我知道應該把這個代碼? window.onbeforeunload = function(){ var isOk = confirm(「Are you sure?」); \t \t \t \t \t \t \t如果(ISOK){\t \t \t \t \t \t的setTimeout( 'document.myForm.submit()',1); } 是這個樣子?但是當我點擊F5進行刷新,該對話框不顯示出來 \t \t \t \t \t \t \t \t} – boon 2013-05-13 23:27:41
啊,我誤解你的問題。我不確定你是否可以做你想問的問題。你可能想看看這篇文章:http://stackoverflow.com/questions/1335727/onbeforeunload-confirmation-screen-custumization – JAM 2013-05-13 23:30:37