Page 1 of 1

Self-closing javascript popup?

Posted: Tue Jan 13, 2004 8:11 am
by Bill H
Okay, I have a popup window used for correcting data that is displayed in html for neatness. The popup is invoked to make a correction and contains an edit box for making the correction as well as code to revise the databse. It works fine but the user must click to close the window after finishing. I would like for it to close automatically after the data is revised.

The window is invoked in the parent by:

Code: Select all

<a href=javascript:firstWindow('reviser.php?Doit=1',130,700)>Preparer:</a>");
Here is the pertinent code in reviser.php:

Code: Select all

<?php
if (isset($_POST['Cash']))
{
     // misc code here processes $_POST var
     mysql_query($Query, $Link);
     // what can I put here to eliminate the "Close Window" href below ????
     // exit;   along with the above line
}
if ($Doit == 1) print("<TITLE>Preparer Text</TITLE>\n");
// misc code here opens database
if ($Doit == 1 || isset($_POST['Prep']))
{
     print("<form method='post' action='reviser.php'>");
     // misc code here displays form
     print("<a href='' target='_parent' onClick='top.close()'>Close Window</a>");
     print("<input type=image src='images/ag_okay.gif'>");
}
?>

Posted: Tue Jan 13, 2004 8:19 am
by igoy

Code: Select all

<?php 
if (isset($_POST['Cash'])) 
{ 
     // misc code here processes $_POST var 
     mysql_query($Query, $Link); 
     // what can I put here to eliminate the "Close Window" href below ????
     echo "<meta http-equiv='refresh' content='2;URL=javascript:self.close()'>"; 
     exit;
} 
?>
Change the value after content= to anything you want, that represent seconds.

Posted: Tue Jan 13, 2004 8:28 am
by Bill H
Wow, that was quick. Thanks.

Posted: Tue Jan 13, 2004 8:32 am
by igoy
:D.... just happened to be lucky I guess....
I'm not even half fast as Nay or Mac....