how to close a child window?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Irvin Amoraal

    how to close a child window?

    Process:
    I have a form which uploads a file from client to server written in PHP.
    When the user presses the submit button, I use the "onSubmit" event to
    execute javascript to open a child window containing some text and an
    animated GIF. The javascript returns 'True' and the file is uploaded. All of
    that works great.

    Problem:
    Now I am trying to close the child window after the file has been uploaded.
    Below is the JavaScript I'm using:

    Observations:
    Error Msg: "progress is undefined".
    I have observed that after form submission the 'if' statement in the 'close
    child window' code fails because the handle 'progress' appears to have no
    value. My guess is that on form submission the handle 'progress' looses its'
    value because the action for the form is to reload itself. The 'if' staement
    does execute because I have placed an 'alert' statement just prior to it an
    the 'alert' executed appropriately.

    If I try to open the window after submitting the form, the page doesn't open
    until after the file has been uploaded, which defeats the purpose.

    Question:
    How do I close the window after the form has been submitted?

    Thanks for your help!
    Irvin.
    _______________ _______________ _______________ __________

    Javascrtip Code:
    _______________ _______________ _______________ __________

    To open the child window:
    <script language="javas cript">
    var progress=null;
    function sendfile() {
    progress=window .open('test2.ht m','progress',' width=350,heigh t=475');
    return true;
    }
    </script>

    To close the child window:
    This code follows my PHP code that verifies the file upload.
    <script type="text/javascript" language="javas cript">
    if (progress && !progress.close d) {
    progress.close( );
    }
    </script>
    _______________ _______________ _______________ ___________


  • Martin Honnen

    #2
    Re: how to close a child window?



    Irvin Amoraal wrote:
    [color=blue]
    > Process:
    > I have a form which uploads a file from client to server written in PHP.
    > When the user presses the submit button, I use the "onSubmit" event to
    > execute javascript to open a child window containing some text and an
    > animated GIF. The javascript returns 'True' and the file is uploaded. All of
    > that works great.
    >
    > Problem:
    > Now I am trying to close the child window after the file has been uploaded.
    > Below is the JavaScript I'm using:
    >
    > Observations:
    > Error Msg: "progress is undefined".
    > I have observed that after form submission the 'if' statement in the 'close
    > child window' code fails because the handle 'progress' appears to have no
    > value. My guess is that on form submission the handle 'progress' looses its'
    > value because the action for the form is to reload itself. The 'if' staement
    > does execute because I have placed an 'alert' statement just prior to it an
    > the 'alert' executed appropriately.
    >
    > If I try to open the window after submitting the form, the page doesn't open
    > until after the file has been uploaded, which defeats the purpose.
    >
    > Question:
    > How do I close the window after the form has been submitted?
    >
    > Thanks for your help!
    > Irvin.
    > _______________ _______________ _______________ __________
    >
    > Javascrtip Code:
    > _______________ _______________ _______________ __________
    >
    > To open the child window:
    > <script language="javas cript">
    > var progress=null;
    > function sendfile() {
    > progress=window .open('test2.ht m','progress',' width=350,heigh t=475');
    > return true;
    > }
    > </script>
    >
    > To close the child window:
    > This code follows my PHP code that verifies the file upload.
    > <script type="text/javascript" language="javas cript">
    > if (progress && !progress.close d) {
    > progress.close( );
    > }
    > </script>[/color]

    That doesn't help, on a new page the variable progress is not defined.
    All you can do on a new page is
    window.open('', 'progress').clo se();
    That way the window with name progress will be closed. Only shortcoming
    is if the user has already closed the window it will be reopened and
    then directly closed again.

    --

    Martin Honnen


    Comment

    • Irvin Amoraal

      #3
      Re: how to close a child window?

      That did the trick.


      Thanks.
      _______________ _________

      "Martin Honnen" <mahotrash@yaho o.de> wrote in message
      news:3fa91e88$1 @olaf.komtel.ne t...[color=blue]
      >
      >
      > Irvin Amoraal wrote:
      >[color=green]
      > > Process:
      > > I have a form which uploads a file from client to server written in PHP.
      > > When the user presses the submit button, I use the "onSubmit" event to
      > > execute javascript to open a child window containing some text and an
      > > animated GIF. The javascript returns 'True' and the file is uploaded.[/color][/color]
      All of[color=blue][color=green]
      > > that works great.
      > >
      > > Problem:
      > > Now I am trying to close the child window after the file has been[/color][/color]
      uploaded.[color=blue][color=green]
      > > Below is the JavaScript I'm using:
      > >
      > > Observations:
      > > Error Msg: "progress is undefined".
      > > I have observed that after form submission the 'if' statement in the[/color][/color]
      'close[color=blue][color=green]
      > > child window' code fails because the handle 'progress' appears to have[/color][/color]
      no[color=blue][color=green]
      > > value. My guess is that on form submission the handle 'progress' looses[/color][/color]
      its'[color=blue][color=green]
      > > value because the action for the form is to reload itself. The 'if'[/color][/color]
      staement[color=blue][color=green]
      > > does execute because I have placed an 'alert' statement just prior to it[/color][/color]
      an[color=blue][color=green]
      > > the 'alert' executed appropriately.
      > >
      > > If I try to open the window after submitting the form, the page doesn't[/color][/color]
      open[color=blue][color=green]
      > > until after the file has been uploaded, which defeats the purpose.
      > >
      > > Question:
      > > How do I close the window after the form has been submitted?
      > >
      > > Thanks for your help!
      > > Irvin.
      > > _______________ _______________ _______________ __________
      > >
      > > Javascrtip Code:
      > > _______________ _______________ _______________ __________
      > >
      > > To open the child window:
      > > <script language="javas cript">
      > > var progress=null;
      > > function sendfile() {
      > >[/color][/color]
      progress=window .open('test2.ht m','progress',' width=350,heigh t=475');[color=blue][color=green]
      > > return true;
      > > }
      > > </script>
      > >
      > > To close the child window:
      > > This code follows my PHP code that verifies the file upload.
      > > <script type="text/javascript" language="javas cript">
      > > if (progress && !progress.close d) {
      > > progress.close( );
      > > }
      > > </script>[/color]
      >
      > That doesn't help, on a new page the variable progress is not defined.
      > All you can do on a new page is
      > window.open('', 'progress').clo se();
      > That way the window with name progress will be closed. Only shortcoming
      > is if the user has already closed the window it will be reopened and
      > then directly closed again.
      >
      > --
      >
      > Martin Honnen
      > http://JavaScript.FAQTs.com/
      >[/color]


      Comment

      Working...