最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - closing the current popup and redirecting to the parent window - Stack Overflow

programmeradmin0浏览0评论

In JS I am using :

window.open('index.php?module=Contacts&action=UD_lookupemailtemplates&tempmode=userdefined&temp_url='+encodeURIComponent(temp_php_url),'emailtemplate','top=100,left=200,height=400,width=500,resizable=yes,scrollbars=yes,menubar=no,addressbar=no,status=yes')

To open a small window which has few links. Now on the click on any one link an id will be attached to the a url and then I used this :

window.document.location.href = url;

This is also in JS. what this does is that it changes the contents of the small popup window but I need it to close the popup window and open this url in the main parent window from where the popup was created.
Is that possible ?

In JS I am using :

window.open('index.php?module=Contacts&action=UD_lookupemailtemplates&tempmode=userdefined&temp_url='+encodeURIComponent(temp_php_url),'emailtemplate','top=100,left=200,height=400,width=500,resizable=yes,scrollbars=yes,menubar=no,addressbar=no,status=yes')

To open a small window which has few links. Now on the click on any one link an id will be attached to the a url and then I used this :

window.document.location.href = url;

This is also in JS. what this does is that it changes the contents of the small popup window but I need it to close the popup window and open this url in the main parent window from where the popup was created.
Is that possible ?

Share Improve this question edited Sep 28, 2012 at 13:46 Gordon 317k76 gold badges546 silver badges565 bronze badges asked Sep 28, 2012 at 13:44 LeonidusLeonidus 4483 gold badges9 silver badges23 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 3

Suppose

var popup_window = window.open(...);

For closing this use

popup_window.close();

and to redirect the parent windows

window.parent.location.href = url;

To close a popup that you opened, store the return value from window.open:

var popup = window.open(...);

Then, you can use:

popup.close();

I'm not clear based on your question where the URL variable is stored (in which window), but you can reference window variables in the popup via popup.variableName.

First you have to redirect parent window using

window.opener.location.href = "http://url."; 

and than close the current (popup) window

window.close();

Personaly I don't like pop up windows instead of that maybe yo can do the following:

You can open an overlay DIV that you can populate with data from "index.php?module=Contacts..." using AJAX and make links inside of that DIV that way so that by clicking them you close that overlay DIV and redirect page to what you want...

发布评论

评论列表(0)

  1. 暂无评论