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>
Unset
onbeforeunloadin the function called bysetTimeoutbefore you redirect the user: