/    Sign up×
Community /Pin to ProfileBookmark

Close a popup window

Please help!
I’ve [color=red]popup[/color] [b]2[/b] difference windows named [color=red][b]“main”[/b][/color] and [color=red][b]“menu”[/b][/color]
And I’ve to creat a link at [color=red][b]“menu”[/b][/color] to [b]close both popup windows[/b]…?
Could anyone help me!???
Thanks!

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@GollumSep 03.2003 — 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...
<i>
</i> 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...
<i>
</i> oMenu.oMain = oMain;


Then in your Menu.html code you could have something like:
<i>
</i>&lt;button onclick="window.oMain.close(); window.close();"&gt;Close both windows&lt;/button&gt;
Copy linkTweet thisAlerts:
@godevilauthorSep 03.2003 — 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+'');
Copy linkTweet thisAlerts:
@steeleweedSep 12.2003 — 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
×

Success!

Help @godevil spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...