Stop the "OnUnload" event in a form

Hi!

Is it possible to stop the “onUnload” event by using JavaScript?

My problem is that I want to do a field check when the user starts to unload the form, if specified field contains a “1” a confirmation prompt shall appear and let the user to choose if they want to continue to the link they had clicked on or to stay in the document.

I´ve tryed to make a funktion that are called upon in the “onUnload” event:

function SaveCheck() {

var Flag = document.forms[0].fldSaveCheck.value;

if(Flag==‘1’) {

if (confirm(‘Message to the user’))

return false;

}

}

Regards

Marie

Subject: Stop the “OnUnload” event in a form

In the HTML Body Attributes add

“onbeforeunload="return SaveCheck()"”

and adjust the function SaveCheck():

function SaveCheck() {

var Flag = document.forms[0].fldSaveCheck.value;

if(Flag==‘1’) {

return ‘Message to the user’

}

}

The message will be prompted within a standard browser text, giving the user the opportunity to click OK or cancel

Regards,

René

Subject: Stop the “OnUnload” event in a form

After taking my second cup of coffee I realized what I had made for misstake :o) Here is a “correct” function if someone want to use it:

function SaveCheck() {

var Flag = document.forms[0].fldSaveCheck.value;

if(Flag==‘1’) {

if (confirm(‘Message to user’))

document.forms[0].submit();

}

}