Self-closing javascript popup?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Self-closing javascript popup?

Post 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'>");
}
?>
User avatar
igoy
Forum Contributor
Posts: 203
Joined: Fri May 02, 2003 11:57 pm
Location: India
Contact:

Post 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.
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

Wow, that was quick. Thanks.
User avatar
igoy
Forum Contributor
Posts: 203
Joined: Fri May 02, 2003 11:57 pm
Location: India
Contact:

Post by igoy »

:D.... just happened to be lucky I guess....
I'm not even half fast as Nay or Mac....
Post Reply