Jump to content

[SOLVED] close window open new link


severndigital

Recommended Posts

ok I am having problems with this one.

 

here is what i want to do.

 

1. open a popup window.

2. when a specific link is click in the new window I want to close it and open the link in the original window that the popup came from.

 

currently I have the code in place to popup the window.

 

I can also close the window with the self.close command.

 

can anyone help me with a function that will close the window and open a link in the original window.

 

or is it even possible??

 

thanks,

chris

Link to comment
https://forums.phpfreaks.com/topic/77723-solved-close-window-open-new-link/
Share on other sites

thanks for that link .. i found what i was looking for.

 

for anyone else .. this how i did it.

 

in the popup window head

<script language="JavaScript">
opener.name = 'main'; //name the opener

function closePopup(link){
window.open(link ,'main');
self.close();
}
</script>

 

then on the link you want to use add this as the href

 

<a href="javascript:closePopup('linkyouwant.htm')">click here</a>

 

that closes the popup and opens the link in the href in the opener window.

 

not sure if it is the 'best practice' but it got the job done for me.

 

thanks again,

chris

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.