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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing a child window 1

Status
Not open for further replies.

GirlFriday1

Programmer
May 1, 2001
20
CA
Hello again!
My question is,,,how do you close a child window using a button? Any suggestions?
Thanks!
 
as long as you assigned the window to a variable, so that you have a way of referring to it...

var x = window.open('thePage.htm', 'theWindow');

then you can just say:

x.close;
 
mkay,,,newbie question,,do I put this in the parent or the child window? I've tried both but they don't seem to work. Is it because I'm using them in a select statement?

Thanks again for the tips Link9! This is a HUGE help! Yer great!!
Thanks!
Your friend, GirlFriday!
 
well, if you're in the child window, and you want to close that, then just say:

window.close();

That will only work w/out a confirmation box if it is a child window that one of your pages has opened... (i.e. - you have "ownership" of that window, and you can do whatever you want with it)

the x.close method should work if it's a valid reference to a window object that you have opened from the parent window (in the parent window, of course) --

:)
 
I was forgetting the () at the end of the statement. You are seriously helping me out of a HUGE jam today, Thanks! Another vote for you! (a small repayment for all of your help!)
 
better check whether your child window is open and do the follwing code

if (x && x.open && !x.closed) x.close();
 
When your closing the child window from in itself
then you can suffice with :
<a href=&quot;JavaScript:self.close;&quot;> Close </a> Everybody has a right to my opinion.
E-mail me at cwcon@programmer.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top