Forum Moderators: open

Message Too Old, No Replies

Close pop up and load page in main window

         

alexswalker

8:12 pm on Jan 17, 2004 (gmt 0)

10+ Year Member



Hi,

I have a page (lets call it window A). If you click on a specific link in window A it loads a pop-up window (lets call this window B). If a user clicks on a link in window B I would like window B be to closed and the link to open up in window A.

How do I do this in js please!

Thanks
Alex

BlobFisk

12:49 am on Jan 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To load a URL from a popup page into the parent page, use:

window.opener.location.href='page.html';

And then to close the popup, use:

self.close();

The best way to approach this is to use a function that does these two actions and then call it from the link. If you plan to use more than one link, use the URL as a variable that is passed into the function.

HTH

alexswalker

10:03 am on Jan 18, 2004 (gmt 0)

10+ Year Member



Thanks for the reply. Just realised I forgot to add that there are 180 versions of the parent page (window A) as I need this pop up to appear for product pages. Therefore I won't know what 'page.html' is!

alexswalker

10:14 am on Jan 18, 2004 (gmt 0)

10+ Year Member



Managed to work it out myself after seraching the Internet:

<script language="JavaScript"><!--
function load(file,target) {
target.window.location.href = file;
self.close();
}
//--></script>

Many Thanks
Alex