/    Sign up×
Community /Pin to ProfileBookmark

Opening a link in a parent window

Hi Guys,

I have a popup window from which I need to open a link into its parent. It works fine on firefox, but it won’t work on IE6 or 7… the code is as follows:

[QUOTE]

if (window.opener != null && !window.opener.closed){
alert(window.opener);
window.opener.location = theLink;
}
self.close();

[/QUOTE]

The alert will appear in both browsers to indicate that the opener exists, but the redirect only works in firefox. Please help it’s driving me nutso!

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@TJ111Nov 27.2007 — Try adding :
<i>
</i>window.opener.location[B].href[/B] = theLink;
Copy linkTweet thisAlerts:
@blue-eye-labsNov 27.2007 — This will only work if the parent window used [CODE]window.open()[/CODE] to open the popup, otherwise it should work as far as I know. Is it necessary to include the window.opener bit though? I mean, will anyone be able to access this popup without it being from a popup?

ANDDD


I just realised that someone answered you much better than I did... :o
Copy linkTweet thisAlerts:
@prigoauthorNov 27.2007 — I tried adding href, and now the code just won't work at all? Added an alert afterwards to check but it appears not to go past

window.opener.location.href = theLink;
Copy linkTweet thisAlerts:
@prigoauthorNov 27.2007 — oh and the parent window did use window.open()...
×

Success!

Help @prigo 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.19,
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,
)...