Forum Moderators: open

Message Too Old, No Replies

links in separate windows

         

legster

11:42 am on Feb 20, 2002 (gmt 0)

10+ Year Member



Ok here is my problem. I have a page in a regular window, and there is a link on that page which pops up a small window with help features. In that help popup window is some links. Currently I have the links on the popup pointing to a new window, so now the user has a total of three windows open.

My boss wants the links in the popup window to point back to the original window.

How can I do this? Any help would be appreciated. Thanks.

tedster

12:26 pm on Feb 20, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can use the window.opener property to access the original window. I use links that look like this:

<a href="#" onClick="window.opener.parent.location=newURL">Link</a>

Something to consider: When the original window loads a new document, the pop-up window loses focus. For this reason, I often add a window.close() to the onClick handler.

legster

12:32 pm on Feb 20, 2002 (gmt 0)

10+ Year Member



I knew you would say that. :)

Thanks Tedster.

Here is my dilemma though. If a person comes to my original pages by other means other than my link, than the whole thing won't work properly. :(

So I'm really kinda looking for a way to do this without naming a link to the original window. I am thinking this is probably impossible, but I can always be hopeful! :)

Thanks again.

MikeFoster

12:34 pm on Feb 20, 2002 (gmt 0)

10+ Year Member



Here's a little javascript function I used for exactly the same thing:

function nav(u)
{
window.opener.focus();
window.opener.location.href = u;
}

Your links can use it like this:

<a href="javascript:nav('myUrl')">click here</a>

Of course, if javascript is disabled, that won't work. In that case, I'm not sure what to do. You can't use the target attribute of the A element, because you don't know the parent window's name. And if the parent window is the initial window... you can't assign a name if javascript is disabled.

Hmmm... I'm sure some of these gurus here knows how to do it. I also would like to know.

MikeFoster

12:36 pm on Feb 20, 2002 (gmt 0)

10+ Year Member



Woah! We all posted about the same time!

I should have refreshed the page before posting

legster

4:43 pm on Feb 25, 2002 (gmt 0)

10+ Year Member



Worked great! Thanks Mike.