Click to See Complete Forum and Search --> : Close a popup window
godevil
09-03-2003, 01:48 AM
Please help!
I've popup 2 difference windows named "main" and "menu"
And I've to creat a link at "menu" to close both popup windows...:confused:
Could anyone help me!???
Thanks!
Gollum
09-03-2003, 03:07 AM
As always there are many ways to skin a cat, here's one...
I'm guessing that your two popups are created by code in your main page with something like the following...
var oMain = window.open("Main.html", "", "main");
var oMenu = window.open("Menu.html", "", "menu");
Now, if you want one window (i.e. Menu) to be able to close the other (Main), then you will need to let it now how to make contact. Something like this should do...
oMenu.oMain = oMain;
Then in your Menu.html code you could have something like:
<button onclick="window.oMain.close(); window.close();">Close both windows</button>
godevil
09-03-2003, 11:26 AM
Sorry...
I've already tried but it didn't worked! :(
Have you got another method!?
I've pop the windows with the below method:
var left_w = 250;
var left_h = 510;
var main_w = 520;
var main_h = 510;
var pop_lw = (screen.width-(left_w+main_w))/2;
var pop_lh = ((screen.height-left_h)/2)-24;
var omain = window.open('main.asp?path=home','main','scrollbars=yes,width=' +main_w+ ',height=' +main_h+ ',top=' +pop_lh+ ',left='+(pop_lw + 260)+'');
var omenu = window.open('left.asp','menu','scrollbars=yes,width=' +left_w+ ',height=' +left_h+ ',top=' +pop_lh+ ',left='+pop_lw+'');
steeleweed
09-12-2003, 01:29 PM
Did something similar at:
http://www.raylsaunders.com/kralor/
I open popup, but close it when we exit the main page, so don't leave the popup hanging out there.
I closed via <body onunload=.....
but you could build a function to close and invoke the function wherever...
G'luck
Ray