troubleshooting Question

call a function before windows.onbeforeunload event triggers

Avatar of Jagadeesh M
Jagadeesh MFlag for United States of America asked on
JavaScript
3 Comments1 Solution2090 ViewsLast Modified:
Hi Experts -

The idea is to check if the form is dirty and display a confirm dialog box to the user to save the page before navigating away....i'm done with 99% of this task using Jquery.

here is the last piece...

Now i need call a function ( callThisAtLast() ) after the user clicks on "OK" confirm dialog box and just before the page unloads...how do i achieve this?

Here is the sample snippets that prompts the dialog box.

Thanks

function callThisAtLast(){
 
;;;;;
 
 
}
 
window.onbeforeunload = confirmExit;
 
function confirmExit(){
      if (verifyIfFormChanged== true ){
	if ( formIsChanged == true ){
	   return "        !!! You have unsaved data on this page !!!";
	}else{
	  if (checkOthers()) {
          
          }else{
	    return "        !!! You have unsaved data on this page !!!";
          }
	} 
     }
}// end of confirmExit()
ASKER CERTIFIED SOLUTION
b0lsc0tt
IT Manager

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros