2

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 is 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();
        }
    }

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for the reply.Any suggestions on how to create my own confirm dialog?
@user461807 - Look at jQuery and the thickbox plugin. jquery.com/demo/thickbox
Thanks a lot but can i achieve this using javascript alone?
@user461807 - jQuery and its plugins are javascript. You can spend lots of time replicating what they do (generating a div in js that is 100% height and width, attaching it to the page etc...). Why do you need to reinvent the wheel?
cause i am doing this for an old application.If I use jQuery i need to add the plugin for this purpose only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.