/    Sign up×
Community /Pin to ProfileBookmark

Action to Parent from Popup of a Popup

Here is the scenario:

Main page has an option to launch a help page in a new window. The help page has a 4-5 questions the answers to which help the user complete a form field on the main page. There is a link on the new window page that launches another new window. This third window has a link that I need to close the first and second popup and also set the selected value of a select box in the main page. I can close both popups using: <a href=”javascript:window.opener.close();self.close()”>. However, I don’t know how to refer to the first window from the third to be able to set the dropdown value. The 1st popup that lauched the second would be window.opener. How would I refer to the main page?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceJun 20.2006 — top.opener.top.opener.document.forms["myFormName"]...
Copy linkTweet thisAlerts:
@betheballauthorJun 21.2006 — Thanks phpnovice. I was able to write some test pages at home and get that to work. However, I am having some problems implementing it on my current project. I thought I would start by simply trying to close the main window, but am getting the, "object doesn't support this property or method" error.

Here is the code for the function called by Page 1

[CODE]
function popIt(url) {
var myPop = window.open(url,"thePop","menubar=1,toolbar=1,resizable=1,scrollbars=1,status=1,height=500,width=500,left=500,top=0")
myPop.focus();
}
[/CODE]


and the link looks like this:

<a href="javascript:popIt('exemption-from-withholding.htm');">

Then, page 2 uses this function:

[CODE]
function newPop2(docTitle,popText)
{
var generator=window.open('','myPop','height=550,width=500,scrollbars=1,status=1');
window.opener="x"
generator.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"')
generator.document.write('"http://www.w3.org/TR/html4/loose.dtd">');
generator.document.write('<html><head><title>'+docTitle+'</title>');
generator.document.write('<link rel="stylesheet" href="../css/layout.css">');
generator.document.write('</head><body>');
generator.document.write(popText);
generator.document.write('<p class="bottomLinks"><a href="javascript:self.close()">Change Answer</a> | <a href="javascript:top.opener.top.opener.close()">Return to Topic</a></p>');
generator.document.write('');
generator.document.write('</body></html>');
generator.document.close();
}
[/CODE]


Am I missing something obvious?
Copy linkTweet thisAlerts:
@phpnoviceJun 21.2006 — What's this all about?

window.opener="x"
Copy linkTweet thisAlerts:
@betheballauthorJun 21.2006 — What's this all about?

window.opener="x"[/QUOTE]


Not sure, it was in the script as I copied it, but that seems to be the cause of the problem. Removed it and the script executed properly.
Copy linkTweet thisAlerts:
@phpnoviceJun 21.2006 — Excellent! ?

Cheers.
×

Success!

Help @betheball 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 5.11,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...