Javascript unload page condition

Posted by Stapped on Stack Overflow See other posts from Stack Overflow or by Stapped
Published on 2010-06-13T12:43:35Z Indexed on 2010/06/13 12:52 UTC
Read the original article Hit count: 191

Filed under:

hello, I am using the following code to prompet 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>

© Stack Overflow or respective owner

Related posts about JavaScript