Forum Moderators: open
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
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. ;)