Notes Ninjas Notes Ninjas
Lotus Notes hints, tips, error messages
Check if window.opener is still open before proceeding

Hint Short Cut: Add this to your code & documentation to help you find this page.
http://www.notesninjas.com/#OpenerStillOpen or http://www.notesninjas.com/A555F9/nn.nsf/ByAlias/OpenerStillOpen


I have been doing some code, (sounds like a problem), for a company's web site. The site opens various sub windows and each has a close button that updates the parent or opener window. Following the first law of demonstration, I closed the windows in the wrong order, and the close button on the child window would not close the window. Very annoying.





So why would the close button and routine no longer work?

Here is the close button code:

<input type=button value="Close"  onClick="javascript:closeWindow();">;

It was because the javascript came up with an error:

Here is the function which was stored in the form's "JS Header" area:

function closeWindow(){
window.opener.rdocprintClosed=true;
window.opener.docprintClosed=true;
window.close()
}

The code above never got to the window.close() as the lines above failed.

here is the code I changed to:

function closeWindow(){
op=window.opener;
if (op && op.open && !op.closed) window.opener.rdocprintClosed=true;
if (op && op.open && !op.closed) window.opener.docprintClosed=true;
window.close()
}

 

Why the three checks?

The checks make sure the window pointer exists, the window was open at some point and the window is not closed.

 


Related Pages: JSBack FocusWindow JSFieldVal JSFieldExists
 Jump to:     Notes Tips
    Lotus Notes Index 
  Register for Tips
Previous Lotus Notes Tip 
    Next Lotus Notes Tip
Your company logo here?
Adam Foster
Free Cash Making Web Site
Free Revenue Earning Blog Site
 Free Revenue Earning Newsletter Site   
Free Search Pages Free Web stats
Free Contact Us page
Cheap .com domain names
 Need a website or 
   Lotus Notes
  problem solved?
Adam Foster
Web Services Platform Architecture: Soap, WSDL, WS-Policy, WS-Addressing, WS-Bpel, WS-Reliable Messaging and More by Francisco Curbera, Frank Leymann, Tony Storey, Donald Ferguson, Sanjiva Weerawarana
Other books claim to present the complete Web services platform architecture, but this is the first one I've seen that really does. The authors have been intimately involved in the creation of the architecture. Who better to write this book?
See at: Amazon.co.uk | Amazon.com |