Javascript timeout
I am using one javascript confirm which will get called after 15 minutes repeatedly.If user selects none of the options in the confirm box i will redirect him after waiting for 1 minute.How to achieve this? My code i开发者_JAVA百科s like
var timeout = 15*60000;
setTimeout("timeoutConfirm();",timeout);
function redirectToClose(){
var action='Some Action';
document.mainForm.action = action;
document.mainForm.submit();
}
function timeoutConfirm(){
if(confirm('Please click OK to continue working on this page')){
setTimeout("timeoutConfirm();",timeout);
}else{
redirectToClose();
}
}
You are better off creating your own confirm dialog (as a overlay, for example).
This is because the confirm
will halt all javascript on the page until the user clicks the dialog. You will not be able to redirect after a wait, as your code will not execute.
精彩评论