By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

Link from a popup needs to open a new parent window

P: n/a
Hello,

I have a problem with a popup. In this popup (child) are several links.
I want these links to open in A NEW parent window.

Code:

<a href="javascript:;"
onclick="opener.location.href='http://www.test.com/'">Link name</a>

This does open the URL in the parent, but in the same window, and not
in a new one (or in case of Firefox, a new window OR a new tab).

There are a lot of samples all over the internet, but they all change
the parent window which is active, and do not create a new one.

Who can help me with a working sample? Or is it just impossible (I have
learnt that nothing is impossible though :)

Thnx,

Rick.

Nov 6 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
ri******@lycos.nl wrote:
Hello,

I have a problem with a popup. In this popup (child) are several links.
I want these links to open in A NEW parent window.

Code:

<a href="javascript:;"
onclick="opener.location.href='http://www.test.com/'">Link name</a>

This does open the URL in the parent, but in the same window, and not
in a new one (or in case of Firefox, a new window OR a new tab).

There are a lot of samples all over the internet, but they all change
the parent window which is active, and do not create a new one.

Who can help me with a working sample? Or is it just impossible (I have
learnt that nothing is impossible though :)

Thnx,

Rick.
Hi,

You don't open a new parentwindow. If you open a new window from another
window, the latter is a childwindow.
In your case you are trying to replace the location of the parent.

If you need a new window, just create it with window.open(...), but it will
NOT be the parent window of the popup.

Also: this is not advised:
<a href="javascript:;" onclick="..">

href="javascript:" is called pseudoprotocol, and should be avoided.

try:
<a href="bla.html" onClick="doYourStuff();return false;">

where bla.html is a reasonable alternative in case people have JS disabled.
the 'return false' makes sure that JS-enabled browsers will NOT follow the
link.

Regards,
Erwin Moller
Nov 6 '06 #2

P: n/a
ASM
ri******@lycos.nl a écrit :
Hello,

I have a problem with a popup. In this popup (child) are several links.
I want these links to open in A NEW parent window.

Code:

<a href="javascript:;"
onclick="opener.location.href='http://www.test.com/'">Link name</a>
If you think you absolutely need to pass by the opener :

<a href="http://www.test.com/"
onclick="opener.foo=window.open(this.href,'','widt h=300,height=300');
return false;">Link name</a>
<a href="http://www.test.com/"
onclick="opener.foo=open.window('','','width=300,h eight=300');
opener.foo.location = this.href;
return false;">Link name</a>
Nov 6 '06 #3

P: n/a
Thank you for these ideas!

(although others may still be posted :)

Nov 6 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.