Link from a popup needs to open a new parent window

R

rick2910

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.
 
E

Erwin Moller

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
 
A

ASM

(e-mail address removed) 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,'','width=300,height=300');
return false;">Link name</a>
<a href="http://www.test.com/"
onclick="opener.foo=open.window('','','width=300,height=300');
opener.foo.location = this.href;
return false;">Link name</a>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top