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

closing windows 1

Status
Not open for further replies.

teroy

Programmer
Oct 17, 2000
67
AU
Hi there. i'm fairly new to javascript and was wondering. I have a page which opens up a new window on a click of a submit button. What i want to know is how to close that window after the next page is loaded? ie the submit button calls a cgi script so i was wondering if i put a window.close in the body onLoad of the next page. But i wasn't sure which window that was going to close. Does anyone have any examples

Much help appreciated

Thankyou in Advance
 
i think once the page is gone, the reference to that window is wiped from memory... so, you don't have a reference to it to close it anymore...

i'm not sure, but that's what i think would happen... adam@aauser.com
 
You could attach something in a query string, like if the window is open...but then you still have to try and call the window by it's name, rather than the variable it was probably assigned to.

You could in someway test the URL of the opener, and if it is different to the one which opened it - close.

Or close the new window onUnload.
This is what I don't get; see, the new window was opened by the parent window (opener) - so theoretically it should still be present in some array of children that the window has? But I have not come across one.

Have you tried onUnload of the opener window? "Alright whatever man, I'll hook up the hair, but I aint touchin the ring...Cause I'm still a pla--yer"
 
thanks guys
The onUnload done the trick. Basically what i was trying to do was upload a file and bring up a "upload in progress" window. It now closes the window when the upload has finished

Thanks once again
 
ah ha... to get a reference to an open window... you can use window.open() an an existing window to get a reference to it... just leave the url parameter blank... adam@aauser.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top