NYCPHP Meetup

NYPHP.org

[nycphp-talk] More Client-Side Grief

(kris)janis p gale sharpwit at hotmail.com
Tue Oct 29 10:47:16 EST 2002


> The problem is, I need to get the parent window (Window 1) to be
> redirected, while the popup (Window 2) closes.  Any ideas on how to
> either:
>
> 1) Have the popup send it's new location (from the PHP form processor)
> back to it's parent.
>
> 2) Or, have the parent see where the popup would be redirected to, and
> redirect itself?
>
> 3) Or something else.

here's some ideas that will work with browsers as ancient or as fresh as you
choose to use...

as someone else suggested (deleted the message already or else i'd give
credit where it's due), you could duplicate the form fields somewhere in the
parent as hidden fields, and create an onsubmit handler in the child that
does nothing more than copy the .value's of its form fields to the parent's
hidden ones, does a .submit() of the form in the parent, and closes itself
via self.close().

OR

if you are determined to have the popup submit itself, and then redirect the
parent as needed, you could still do that...  have the parent pop up the
child window, as usual, the form in the child submits as any other form
would (i assume with a php script as the action=), and the script that acts
on that form could include a very basic html document with a bit of
javascript that is an onload handler for the body tag...

[html]
[head]
[script type="text/javascript"]
function allDone()
{    parent.location = "newlocation/fortheparent.php";
      self.close();
}
[/script]
[/head]
[body onload="allDone()"]
 
[/body]
[/html]

either method will work well, but the second route doesn't require the
redudant hidden fields and whatnot.
hope this helps!
- kris




More information about the talk mailing list