Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close the child window in another page

Status
Not open for further replies.

klwong

Programmer
Dec 7, 2001
14
0
0
HK
I have opened a child window using JavaScript in a JSP, abc.jsp

child = window.open("....");

How can I pass the 'child' to another jsp, say, another.jsp
and I will close the window in another.jsp by child.close()?

Thanks
 
To send the child window forward...
child.location.href='another.jsp';

What do you mean by the other part? Do you want to close any already open windows whose locations are another.jsp?
If you want to close the child window, what you have is right:
child.close();

Rick
 
Going out on a limb here. On the assumption that Java Server Pages are like ASPs, that is abc.jsp is a program that builds an HTML page with a <SCRIPT> in it.

The document in the child window can have a script that references the parent window and closes it with

window.opener.close();

If the document in the child window is built by another.jsp then it can close the parent window. The child window has a property, opener, which is the parent window. So you don't have to pass this information, the browser already has it.

 
Hi,

Yes, jsp is similar to asp such that it can form a HTML with javascript functions

what I want to do is something like that..
Window 1: abc.jsp -> new.jsp
| |
Winodw2: child open child close when an event is triggered

How can I pass the child to new.jsp?
and how can I receieve the child in new.jsp?

Thanks
 
If I understand you correctly, this is what you want--:

window.opener.location.href=window.opener.location.href;
self.close();

That goes in the child window where the event is executed.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top