ok i need to self close a window (like after 5 seconds)

anyone knows the command to close the window?

would

echo "self.close()"; 

?

be correct?

  • hanhao

    PHP can't do this because it doesn't know what a "window" is.

    Javascript could do it, though. Something like

    <script type="text/javascript">self.close();</script>

    Though you'll probably need to search the net a bit to see how Javascript does timers (I can never remember, so that's what I end up doing every time I need to do it. SetTimeout() or something like that.)

      5 days later

      Yeah... I have trouble with it too, so here's my guess:

      <script type="text/javascript"> setTimeout("self.close()", 5000); </script>

        That is the correct syntax, but be aware that you can only close a window with scripting, that you opened. You can't close the initial window used to navigate to your site. IE will throw up a prompt asking if the user wants to allow, and the other major browsers just ignore it.

          5 years later
          bradgrafelman;10730924 wrote:

          Yeah... I have trouble with it too, so here's my guess:

          <script type="text/javascript"> setTimeout("self.close()", 5000); </script>

          your are correct put this query outside of the PHP tag

          [INDENT]if(!$result) {
          die("Record Not Added".mysql_error());
          }else {

          echo "Successfully Updated 1 Record ";

          ?>

                  <script type="text/javascript"> setTimeout("self.close()", 300); </script>

          <?php
          }
          ?>[/INDENT]

            Write a Reply...