Forum Moderators: open

Message Too Old, No Replies

closing opened window

         

ucbones

10:21 am on Aug 30, 2004 (gmt 0)

10+ Year Member



Hi,

I want to open a window when a form is processed, that closes when the script the form is posted to finishes running. I can open the window no problem:

popup=window.open('http://www.example.com', 'popup', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=350,height=350,left = 362,top = 234');

But when I close it from the page that loads- so not the page that opened the window, obviously the variable popup is not set- is there any way of doing this elegantly?

Many thanks,

ucbones

Rambo Tribble

12:46 pm on Aug 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



self.close();

ucbones

1:00 pm on Aug 30, 2004 (gmt 0)

10+ Year Member



Sorry,

I wasn't clear, I want to send a command to the popup window I opened from the browser window that opened it, though the page in the window that opened it will have reloaded.

Many thanks,

ucbones

BillPosters

1:03 pm on Aug 30, 2004 (gmt 0)



I'm a bit rusty with js, but…

You could repeat the window.open function in any subsequent page and follow it immediately with the close() function.

e.g.


function closePop() {
var popup = window.open('', 'popup');
popup.close();
}

As long as the window's js name attribute (the attribute 'popup' within the window.open() command) is the same in both functions, the existing pop-up ('popup') will be reused as the target of the closePop() function, which will acquaint the current page with the pop-up window.

Once they are acquainted, you can use popup.close() just as you would from the pop-up's true parent window.
Slip in the close() instruction asap by making it all part of the same function.

I can't help thinking that there is an easier, less roundabout way, but it's been an age since I last messed about with js and my knowledge of js is now a bit patchy. ;)

ucbones

1:31 pm on Aug 30, 2004 (gmt 0)

10+ Year Member



Works a charm! Thanks!

ucbones