Obtain Button Value When OnBeforeUnload Executed

C

crjunk

I have a script notifies the user to save their changes if they try to
close the browser or leave the current page. My problem is that if
they click on the "Save Changes" button, the script executes.
Obviously, I don't want to remind the user to save their changes when
they are trying to save their changes.

Here is the original script that I have:

window.onbeforeunload = SaveChangesPrompt;
function SaveChangesPrompt() {
if ((document.ScheduleForm.txtRecordStatus.value) == "Changes Made;
Record Not Saved.")
{
return "YOUR CHANGES HAVE NOT BEEN SAVED.";
}
}

I tried adding the following to the IF statement, but it doesn't seem
to have any effect:
&& ((this.value) != "Save Changes")

Is what I'm trying to accomplish possible?

Thanks,
CR Junk
 
C

crjunk

I figured out a work-a-round by adding an OnClick event to my button.
With the OnClick event, I am writing out "Ignore" to a hidden input
field. I then added " && document.ScheduleForm.txtHdnIgnore.value !=
"Ignore" to my IF statement. I don't know if this is the best way to
do this, but it works.

Thanks,
CR Junk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top