重定向父窗口

i have a question :

when i open a popup window(validation information)

当我打开一个窗口的时候 弹出一个登录的窗口(验证信息,因为是未登录的状态)

from its parent window, after validation succeed, it should close

在输入验证信息后,关闭验证信息窗口,并且主窗口应该刷新成登录的状态

popup window,then refresh parent window( to login state),

but how should i do to refresh its parent window ( to login state)?

我在验证信息窗口 应该怎么做才能刷新主窗口为登录的状态呢?

(this is the code to open popup window :

/**

  • 弹出的登录窗口(表单)

*/

public function actionPopLogin(){

// 登录(login)

$loginInfo = $this->getPost(‘LoginForm’);

if($loginInfo){

$login = new LoginForm;

$login->attributes=$loginInfo;

if($login->validate() && $login->login()){

echo "<script>parent.ClosePop();</script>";//close popup window

//here,how to write code make parent window refresh to login state

//$this->redirect(Yii::app()->user->returnUrl);这样不行

}

}

$this->renderPartial(‘poplogin’,’’,false,true);

}

any help be appreciated!


<script>parent.ClosePop();</script>";//close popup window

//here,how to write code make parent window refresh to login state

//$this->redirect(Yii::app()->user->returnUrl);这样不行

这块因为redirect使用的是header()进行重定向,你之前输出了(echo "<script>parent.ClosePop();</script>";),header信息已发送,肯定是不能跳转的。

你可以使用js跳转,使用clientScript->registerScript()输出一段js,操作window.opener或者top(iframe的话),操作location.href就可以了

thank you ,

echo "<script>parent.window.location.href=parent.window.location.href;parent.ClosePop();</script>";