Amaya Gomez: Focus transfer between browser windows

I would be grateful if someone could give me a tip to my problem:

  • I have two HTML-Pages containing both a Java Script (JDK 1.1).
  • The user opens a Browser window containing the first page.
  • When the Java Script at this page is executed, it opens a new browser window containing the second page, using the window.open("HTLM-Page name") method.
  • That means a Java Script contained in the second window can handle the first one using the window.opener object reference.
  • I want to give the user the oportunity to go back from the second window to the first one. All I have to do is to call the method window.opener.focus(). The problem is, if the user already closed this first window, I can‚t transfer the focus anymore. I have to create then a new window containing the page at this first window.
  • My question ist how can I ask whether the first window was closed or if it's still opened?
  • I already tried to ask for the property window.opener.closed, but it always gives the value "false" back no matter if the first window is closed or not.

Tank you very much.

  1. Hello Amaya,

    i check for the existance of opener's window in this way - it works 8)

    if(opener.location)
    {
    //   do whatever you want ...
    return;
    }
    else
    {
    Check = confirm("1st window already closed, retry ?");
    if(Check==true)
    {
      mainframe = window.open('1st.htm','firstwindow','locationbar=yes,menubar=yes,status=yes,toolbar=yes,scrollbars=yes,resizable=yes');
    self.close();
    }
    }
    kind regards   Guenter