Click to See Complete Forum and Search --> : How to reference original window from a pop up


damon2003
11-18-2003, 04:19 AM
Hi,
I have a javascript pop up window with a link in it. When the link is clicked, I want the original window where the popup started to transfer to the link. How can I reference the original window?
thanks

fredmv
11-18-2003, 04:20 AM
<a href="http://www.google.com/" onclick="window.opener.location.href = this.href; return false;">Google in parent window.</a>

Gollum
11-18-2003, 04:20 AM
use window.opener in the popup to reference the window that opened the popup :)

damon2003
11-18-2003, 04:23 AM
thats great, thanks,
one more thing,
I only want one popup window of the same name to be opened at a time (there will be several links for popups on a page). How can I make a check to see if a particular pop is already open?
cheers

fredmv
11-18-2003, 04:25 AM
If you have a variable that is a reference to the new window, you could check it's existence as easily as this:

<a href="#" onclick="(typeof referenceToWindow != 'undefined') ? alert('It exists') : alert('It does not exist.');">Does the new window exist?</a>