tags:

views:

33

answers:

1

hello, I am using the following code to prompt the user that if he left the page he can't come back. Things happened that i want to redirect the page using setTimeout function after a specific time. I want to disable checking for user leaving the page when the automatic redirection starts.

<script language="javascript" type="text/javascript">
        needToConfirm = true;
        window.onbeforeunload = askConfirm;

        function askConfirm(){
            if (needToConfirm){
                return "Please note that you might not be able to come back and watch the movie again.";
                }
            }
    </script>
A: 

Unset onbeforeunload in the function called by setTimeout before you redirect the user:

window.onbeforeunload = null;
Marcel Korpel
Wow that worked. Thanks so much
Stapped