Loading ...
Sorry, an error occurred while loading the content.

How to use CGI to Close a Window?

Expand Messages
  • Will K.
    Greets Folks, Does anyone know how to use Perl to close a browser after a form has been filled out and submitted, but still ensure that the form contents reach
    Message 1 of 5 , Dec 30, 2001
    • 0 Attachment
      Greets Folks,

      Does anyone know how to use Perl to close a browser after a form has been
      filled out and submitted, but still ensure that the form contents reach
      their destination? I hope I'm being clear...

      What I want to do is enable the user to click a button and popout a new
      window with a fillout form, and then when they click submit to send the info
      to the cgi script the window will close out. I've seen this done, but never
      understood how it is accomplished. I'm using Javascript to open the window,
      but I'm hestitatant to using most of the "Close Window" scripts because they
      close the window before the information is sent. I want to make sure the
      form data is returned to the server before the window is turned off, so I
      was thinking if I put the "close" command somewhere in the CGI (like at the
      end of the script), then I might avoid this problem because the script will
      already have run.

      Seems like a cool technique becauase the "On Click" would enable the user to
      open the form at will, but then when they are done it would close the form
      window so that the desktop doesn't get "littered" with excess browsers.

      Any input much appreciated.

      I hope everyone's having Happy Holidays out there too!
      =)

      Will K.

      _________________________________________________________________
      Join the world�s largest e-mail service with MSN Hotmail.
      http://www.hotmail.com
    • Peter Kirby
      ... CGI executes on server side, to close a window you need to get on the client side. You might do this by sending a page to the window from the CGI with a
      Message 2 of 5 , Dec 30, 2001
      • 0 Attachment
        At 11:48 PM 12/30/01 +0000, you wrote:
        >Greets Folks,
        >
        >Does anyone know how to use Perl to close a browser after a form has been
        >filled out and submitted, but still ensure that the form contents reach
        >their destination? I hope I'm being clear...
        >
        >What I want to do is enable the user to click a button and popout a new
        >window with a fillout form, and then when they click submit to send the info
        >to the cgi script the window will close out. I've seen this done, but never
        >understood how it is accomplished. I'm using Javascript to open the window,
        >but I'm hestitatant to using most of the "Close Window" scripts because they
        >close the window before the information is sent. I want to make sure the
        >form data is returned to the server before the window is turned off, so I
        >was thinking if I put the "close" command somewhere in the CGI (like at the
        >end of the script), then I might avoid this problem because the script will
        >already have run.
        >
        >Seems like a cool technique becauase the "On Click" would enable the user to
        >open the form at will, but then when they are done it would close the form
        >window so that the desktop doesn't get "littered" with excess browsers.
        >
        >Any input much appreciated.

        CGI executes on server side, to close a window you need to get on the
        client side. You might do this by sending a page to the window from the
        CGI with a JavaScript that will automatically close the window. IE, the
        page that you output with Perl will contain the JavaScript code for closing
        a window, and then it will happen after the CGI has executed.

        best,
        Peter Kirby
      • Richard Taylor
        ... From: Peter Kirby To: Sent: Sunday, December 30, 2001 3:54 PM Subject: Re: [PBML] How to use CGI to
        Message 3 of 5 , Dec 30, 2001
        • 0 Attachment
          ----- Original Message -----
          From: "Peter Kirby" <kirby@...>
          To: <perl-beginner@yahoogroups.com>
          Sent: Sunday, December 30, 2001 3:54 PM
          Subject: Re: [PBML] How to use CGI to Close a Window?


          > At 11:48 PM 12/30/01 +0000, you wrote:
          > >Greets Folks,
          > >
          > >Does anyone know how to use Perl to close a browser after a form has been
          > >filled out and submitted, but still ensure that the form contents reach
          > >their destination? I hope I'm being clear...
          > >
          > >What I want to do is enable the user to click a button and popout a new
          > >window with a fillout form, and then when they click submit to send the
          info
          > >to the cgi script the window will close out. I've seen this done, but
          never
          > >understood how it is accomplished. I'm using Javascript to open the
          window,
          > >but I'm hestitatant to using most of the "Close Window" scripts because
          they
          > >close the window before the information is sent. I want to make sure the
          > >form data is returned to the server before the window is turned off, so I
          > >was thinking if I put the "close" command somewhere in the CGI (like at
          the
          > >end of the script), then I might avoid this problem because the script
          will
          > >already have run.
          > >
          > >Seems like a cool technique becauase the "On Click" would enable the user
          to
          > >open the form at will, but then when they are done it would close the
          form
          > >window so that the desktop doesn't get "littered" with excess browsers.
          > >
          > >Any input much appreciated.
          >
          > CGI executes on server side, to close a window you need to get on the
          > client side. You might do this by sending a page to the window from the
          > CGI with a JavaScript that will automatically close the window. IE, the
          > page that you output with Perl will contain the JavaScript code for
          closing
          > a window, and then it will happen after the CGI has executed.
          >
          > best,
          > Peter Kirby
          >

          I would use the onsubmit event handler. This is what it's meant for. You
          can use the same function to validate the form as well. If you return false
          to the form in any place it won't submit. If you want more details with
          regards to this no problem.

          The other thing that I think looks pretty cool is this.

          User clicks hyperlink to fill out your form
          They submit the form to yourpage.cgi - refreshing the popup window
          yourpage.cgi's onload fires off a function that looks sort of like this.
          The page says thank you for submitting your form and disappears about the
          time they've finished reading it.

          function closeWindow()
          {
          settimeout(window.close, 2000); //where 2000 = 2000 milliseconds
          i've found 2-3 to be ideal
          }

          onload="javascript:settimout();"

          It also may require that you pass a function instead of calling the
          window.close() method as the first paramater. If it does just have a
          function close window that has one line of code ... close.window();

          I also did the research and settimeout's been in javascript since 1.0. I
          don't know if it was in the beta version for NN 2.0 - then again almost
          nobody run's this. Nice thing about the effect is they can close the window
          themselves if it doesn't work.

          Regards,

          Richard Taylor
        • Will K.
          I think the second way you mentioned works best. If the person submits a form, and then the browser just closes out without telling them the form was
          Message 4 of 5 , Dec 30, 2001
          • 0 Attachment
            I think the second way you mentioned works best. If the person submits a
            form, and then the browser just closes out without telling them the form was
            successfully delivered, then they're likely to wonder if it was actually
            sent. The second way you suggest actually gives them some validation, and
            they're not left wondering.

            Thanks for the help everyone! =)

            Will K.

            =====================

            I would use the onsubmit event handler. This is what it's meant for. You
            can use the same function to validate the form as well. If you return false
            to the form in any place it won't submit. If you want more details with
            regards to this no problem.

            The other thing that I think looks pretty cool is this.

            User clicks hyperlink to fill out your form They submit the form to
            yourpage.cgi - refreshing the popup window yourpage.cgi's onload fires off a
            function that looks sort of like this. The page says thank you for
            submitting your form and disappears about the time they've finished reading
            it.

            function closeWindow()
            {
            settimeout(window.close, 2000); //where 2000 = 2000 milliseconds
            i've found 2-3 to be ideal
            }

            onload="javascript:settimout();"

            It also may require that you pass a function instead of calling the
            window.close() method as the first paramater. If it does just have a
            function close window that has one line of code ... close.window();




            _________________________________________________________________
            Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
          • Bompa
            ... How about submitting with a link? Then just use onclick close or whatever. Bompa
            Message 5 of 5 , Dec 30, 2001
            • 0 Attachment
              "Will K." wrote:
              >
              > Greets Folks,
              >
              > Does anyone know how to use Perl to close a browser after a form has been
              > filled out and submitted, but still ensure that the form contents reach
              > their destination? I hope I'm being clear...


              How about submitting with a link? Then just use 'onclick' close or whatever.

              Bompa
            Your message has been successfully submitted and would be delivered to recipients shortly.