Tuesday, August 8, 2006

onBeforeUnload (devWorks Posting)

I posted this yesterday with no response. You can respond back here or over at devWorks if you wish.

Link to Post

I have read everything in this forum regarding onbeforeunload and have also checked out codestore.net. I have a nearly functional web document locking implementation now; thanks to help here.

However, I cannot figure out how to prevent a second invocation of the onbeforeunload event when the OK button is selected in the onbeforeunload event window.

Here is my basic config for the form:
HTML Body Attributes: "onbeforeunload=\"beforeunload();\""

JS Header:
function beforeunload() {
msg = "----------------------------------------------------------\n";
msg += "Your tech support form has not been saved.\n";
msg += "All changes you have made will be lost\n";
msg += "----------------------------------------------------------";
if (isEditMode && isLocked){
if (document.forms[0].closewarning.value="Yes") event.returnValue = msg;

if (isEditMode && isLocked) {
location.href = DBURL + "webunlock?openagent&unid=" + DocUNID;

Currently, if I navigate away from the locked document in edit mode, I get the onbeforeunload OK/Cancel window. If I click Cancel I return to the document. If I click OK, then I get the onbeforeunload AGAIN! Clicking OK will then unload and unlock the document.

How can I prevent the second instance of the onbeforeunload window?

Now Playing: "Facedown" by Matt Redman

1 comment:

Anonymous said...

Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!