2016-03-05 131 views
0

我完成了与社交网站的登录,但我遇到了麻烦,我怎样才能使我的弹出窗口关闭并刷新成功后的父页面登录窗口弹出关闭并刷新成功登录时的父页面Facebook

这里是我目前的做法(这可能不会帮助你,但我只是想让你知道,我已经做了我的工作)这是我的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(); 
     } 
    } 

我的HTML:

<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'); 
} 
+0

关闭弹出窗口,你可以做window.opener前.location.reload(); na – rahul

+0

@Plum这是我的问题我不知道我该如何使用它以及在哪里放入 –

+0

如何关闭弹出页面 – rahul

回答

0

添加像这样在您的视图页面: -

if($user_profile) echo '<script>window.close(); 
     window.opener.location.reload();</script>'; 
相关问题