how do i close a specific window. (not the active one) with javascript.
the reason im asking is because i have a form submitting to another page AKA TARGET_BLANK.
but i have it target blank because that page checks if the stuff from the form can be inserted into the database.

BUT IF IT CANT, i give them a close(the active page) link and it closes the second page(that says oh u didnt fill in a title THE ERROR blah blah blah)
so that the user can fix the first page(the page didnt reload itself or close so the information can stay and not be lost(form inputs, textarea texts etcc)

but what if the user submits a correct form and it says so on the 2nd page. and then close that page right AND THEN... theres the first page there left un touched.

thats why im asking how can i get page 2 to close page one. with javascript

7 Years
Discussion Span
Last Post by SKANK!!!!!

target='_blank' creates a new unnamed window
target='Ralph' creates a new named window, Ralph, Ralph (mywindow, detail, example etc) can be accessed by javascript
the window can be closed <a href='#' onclick='Javascript:Ralph.close();' > Close popup </a> for most people this will not be neccessary or effective as their popup blocker will not allow javascript to open a new window

Layers, css layers can contain whatever you display in the new window without being blocked


so if javascript can close a window by name what if i want the original window closed(closed by the target-"ralf" window i make from it?


then you will get a close confirmation dialog, closing the initial window will kill your browser history.

most forms can be self processing, then this problem does not exist
action = self (in whatever language the form is written in)
and value of fields is $_post value if $post is set allowing each field to be sequentially corrected and reposted
submission is not made to the database untill the form validates

<?php /* validate form  if ok submit & redirect to next page, echo the form if failure */ 
echo "<form method='post' action='".$_SERVER['PHP_SELF']."'>";
. "Name <input type='text' name='name' value='".$_POST['name']."'><br>";
."Address <input type='text' name='address' value='".$_POST['address']."'><br>";
."<input type='submit' value='Go Nuts'></form>"; ?>

the code sample is BS just to demonstrate inline possibilities

If the form in the popup window validates and submits, then in that form you can redirect the initial window, using the opener property in the popup, each window remembers its parent and its opener



Edited by almostbob: n/a


no i cant do it that way i have to have the option to close the first window with the seocnd

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.