troubleshooting Question

body onload and unload problem..

Avatar of sandsgaucho
sandsgaucho asked on
JavaScript
15 Comments1 Solution1272 ViewsLast Modified:
Hi,

I need to do the following: When the user tries to close the browser/ perform refresh or navigate to another page, display a confirm box and if the user clicks on CANCEL, the action should be killed.

I  have body tag as follows:

<body leftmargin=0 topmargin=0 marginheight="0" marginwidth="0" bgcolor="#ffffff" onload="closure();ini('<%=npass%>');" onunload="confirmClose">

and my confirmClose is :

function confirmClose() {
var agree=confirm("Sure u want to close/ navigate away?");
if (agree) {
      return true ;
} else {
      return false ;
      }

}

The problem is that the unload function is simply not being executed... whats stranges is that if I remove the onload functions, it executes fine..

any suggestions ?

TIA
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 15 Comments.
Join the Community
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 15 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