Help needed on window.close() started from LotusScript

I am using a web form (which is created with window.open()) to input data in one field.

I do an input validation check and if passed the doc is saved and the window should be closed.

The error checking is working fine. When not passed the form is reloaded to correct the input. HOWEVER when the input is ok (and the window should be closed), the window stays. I have looked through all the forum and tried a lot of things, but to no avail.

I am using 6.01 for domino and Notes Designer. IE 6 for Browser.

Here’s the code:

'Error Check A1: CategoryName empty?

If doc.LinkCategory(0) = "" Then

	doc.Error_A1 = 1

	doc.VerifyInput = 1

	Call doc.Save(True,True)

Else

	doc.Error_A1 = 0

	Call doc.Save(True,True)

	Print {<SCRIPT language="JavaScript">self.close()</SCRIPT>}

End If

Instead of self.close() I have tried close(), top.close() etc. as suggested in this forum.

Can you please help. This is driving me crazy.

Thank you very much.

Richi

Subject: if this is a pop up window, can’t autoclose

Can’t remember the exact reason, but if it’s a popup window, you cannot cause the window to close while in the flow of a normal script.

You have to put the close command in a button and manually click it (i.e. tie the command to the onclick event).

You’ll notice all web sites do this that provide pop up windows.

Again, I can’t remember the exact reason, but it’s an HTML/Javascript issue not specific to Domino.

  • Matt

Subject: Did you try “window.close()” as well?

Subject: RE: Did you try “window.close()” as well?

Hi Bill

Yes, I tried a lot of combinations such as window.close(), self.close(), top.close(), close() but yet to no avail.

Maybe I really have to follow the advice to close the window “manually”, i.e. providing a button at the end of the entry process to close the window.

or have you come across any other good method?

Thanks for your help.

Richi

Subject: help needed on window.close() started from LotusScript

Okay. I had a very similar problem to you just today which I managed to resolve so I hope this helps you.

What I was doing was opening a dialog window from a parent document using JS window.open, then populating fields in the dialog window and then clicking a button which validated the form and then saved it and closed the window, hence returning the user to the parent document.

What you need to do is write a JS validation routine to perform your validation, don’t use Lotus Script. Put this function in the JS Header of your dialog form. For example:

frm = document.forms[0];

function doValidate(){

if(frm.FieldName.value==""){

    alert("Please enter a value into field");

    return false;

};



//return true if there are no validation erros.

return true;

};

Once you’ve done, you can call it by putting a done or submit button on the form with the following code.

frm = document.forms[0];

if(doValidate() == true){

//This is the command to do a FileSave, FileCloseWindow

frm.submit();

};

Now this is where I had problems. If you put window.close(); after the frm.submit() call (above) you will find that the form won’t save. I think this is becuase IE or rather the JS interpeter doesn’t wait for the frm.submit() to complete - it continues on with the window.close(); function. I think this was what Matt was saying in another post…

What I had to do is create a new form, completely blank. Call it something like… “Window Close Event” with an alias of “frmCloseEvent” for instance. Now in this form’s JS onload event put the JS code window.close();

Now back to your dialog window, create a $$Return field, make it computed and hidden from the web. Now you need to enter this code.

DBPath:=@ReplaceSubstring(@Subset(@DbName; -1); " " : “\”; “+” : “/”);

“[”+DBPath+“/frmCloseEvent?OpenForm]”

To explain this process step-by-step;

  1. You click a button on the parent document, which opens your dialog window.

  2. Enter the relavent information into dialog

  3. Click the submit/done button

  4. The JS Validation code is triggered

  5. If it is passed the form is saved

  6. The $$Return field opens the frmCloseEvent form

  7. When the frmCloseEvent form is opened the onload javascript event is triggered which closes the window.

That’s it. Sorry it’s a bit verbose but I like to make sure I get everything down so you understand the fist time around!!! :slight_smile:

I hope this helps you resolve your problem. This solution actually prove’s that it is possible to make a web dialog window close automatically, Matt said that it was not possible… and I would have agreed with him until about an hour ago!

Cheers,

Andrew