Problem with onUnload with Netscape 4.04

Luc Grondin grondin.luc at uqam.ca
Mon May 11 17:10:07 EDT 1998


Hello

I while back someone posted a message regarding this JavaScript Event
handler.  I have a problem too.

I am using a "window.open" to have an information window open when the user
click on a hyperlink.  I would like to make sure that this window closes
when the patron leaves the parent Web page.  This is what I did:

  <script language="Javascript1.1">
  var info = null;
  function Fenetre(URL)
        {

info=window.open(URL,'message','toolbar=no,width=660,height=350,directories=
0,status=0,scrollbars=1,resizable=1,menubar=0')
        }  
  </script>
  </HEAD>
  <BODY onUnload="info.close()">
  ...
  <A HREF="JavaScript:Fenetre('codes.html')">liste des codes</A>
  ...

It works, but I get an error message when I reload the page, after having
closed the child window: "info has no properties".  In other words, if I
try to leave the parent window without having the child window opened, I
get the error message.

I guess that I will have to replace the "info.close" by a function that
checks if the child windows is opened: do nothing if it is not there,
info.close() if the info window exists.

Any idea?


I could put a "setTimeout" in the child Window, but I find that solution
less elegant.

Thank you in advance for your help



mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
               Luc Grondin
         Bibliothecaire/Librarian
  Services informatises des bibliotheques
      Universite du Quebec a Montreal
mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm



More information about the Web4lib mailing list