PDA

View Full Version : link back to main window from pop-up - link in href=""


AdamC
09-25-2002, 11:23 AM
I need a script for a link in a pop-up window that links back to the main window AND has the linked page in the href="" area.

i.e.

something like

<a href="mylink.html" onClick=( enter the magic here )>

Thanks!

glenngv
09-25-2002, 12:08 PM
<a href="mylink.html" onClick="this.target=window.opener.name">

AdamC
09-25-2002, 12:12 PM
Just tried it, and it opens the link in a new window.

Is there an adjustment I need to make?

jolietjake
09-25-2002, 12:33 PM
Well, if the main window has no name, then the window.opener.name returns null...

try to put window.name='mytopwindow' on the main page, then the script will work

requestcode
09-25-2002, 01:37 PM
Why does the url have to be in the href? It would be simple to do this:
<A HREF="#" onClick="opener.location='mypage.html'">Click</A>

The term "opener" refers to the window that opened the popup.

AdamC
09-25-2002, 01:59 PM
it needs to be in the href for the benefit of search engine spiders, which cannot follow links within javascript code.

Garadon
09-25-2002, 03:05 PM
<A HREF="mylink.html" Target="javascript:parent.location;">Click</A>

adios
09-25-2002, 05:00 PM
My 2p:

In the main window (somewhere):

<script type="text/javascript" language="javascript">

self.name = 'AdamC';

</script>

In the pop-up link:

<a href="mylink.html" target="AdamC">