我已经完成了社交网站的登录,但是我遇到了一个麻烦,如何在成功登录后关闭弹出窗口并刷新父页面
这是我目前的方法(这可能对你没有帮助,但我只是想让你知道我已经完成了我的工作)这是我的JS:
function PopupCenter(url, title, w, h) {
// Fixes dual-screen position Most browsers Firefox
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
var left = ((width / 2) - (w / 2)) + dualScreenLeft;
var top = ((height / 2) - (h / 2)) + dualScreenTop;
var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
// Puts focus on the newWindow
if (window.focus) {
newWindow.focus();
}
}
我的网页:
<a href="<?php echo base_url()?>hauth/login/Facebook" target="popup" onclick="PopupCenter('<?php echo base_url()?>hauth/login/Facebook','xtf','900','500'); return false;">
并识别用户是否已连接(位于Hauth/登录控制器上)
if ($service->isUserConnected())
{
log_message('debug', 'controller.HAuth.login: user authenticated.');
$user_profile = $service->getUserProfile();
log_message('info', 'controllers.HAuth.login: user profile:'.PHP_EOL.print_r($user_profile, TRUE));
$data['user_profile'] = $user_profile;
$this->load->view('hauth/done',$data);
}
else // Cannot authenticate user
{
show_error('Cannot authenticate user');
}
在您的视图页面中添加如下内容:-
if($user_profile) echo '<script>window.close();
window.opener.location.reload();</script>';