1

当facebook弹出窗口打开时,输入电子邮件和密码后;弹出窗口不关闭。成功登录后应该加载的页面会在弹出窗口本身中加载。如果我手动关闭此弹出窗口并刷新父页面,那么一切正常。

我在javascript中使用了windows.close和window.opener.location.reload函数,但它似乎不起作用

我正在使用代码点火器:

我的控制器

    <?php
class Landing extends CI_Controller {
    private $user = null;
    public function __construct()
    {
        parent:: __construct();
        parse_str($_SERVER['QUERY_STRING'], $_REQUEST);     
        //print_r($this->session->all_userdata());
        $redirect_url = (isset($_GET['redirect_url'])) ? $_GET['redirect_url'] : '';
        if($this->session->userdata('loginStatus')) {
            if($redirect_url && $redirect_url !=='') {
                redirect($_GET['redirect_url']);
            } else {
                redirect('home');
            }
        }


        $this->load->library('fb_api/facebook', array("appId" => $this->config->item('appId') , "secret" => $this->config->item('secret')));
        $this->user = $this->facebook->getUser();

    }

    public function index(){
        if (isset($_REQUEST['state']) && isset($_REQUEST['code'])) {
                echo "<script>window.close();window.opener.location.reload();</script>";
            } else {
                // load page
            }

        if ($this->user) {
          try {

看法:

<script type="text/javascript">
    var baseUrlJs = '<?php echo base_url()?>';
    var sessMemLayer = "<?=$this->session->userdata('loginStatus')?>";
    <?php if ($loginFbUrl) { ?>
    var newwindow;
    var intId;
    function loginFB(){
        var  screenX    = typeof window.screenX != 'undefined' ? window.screenX : window.screenLeft,
             screenY    = typeof window.screenY != 'undefined' ? window.screenY : window.screenTop,
             outerWidth = typeof window.outerWidth != 'undefined' ? window.outerWidth : document.body.clientWidth,
             outerHeight = typeof window.outerHeight != 'undefined' ? window.outerHeight : (document.body.clientHeight - 22),
             width    = 500,
             height   = 270,
             left     = parseInt(screenX + ((outerWidth - width) / 2), 10),
             top      = parseInt(screenY + ((outerHeight - height) / 2.5), 10),
             features = (
                'width=' + width +
                ',height=' + height +
                ',left=' + left +
                ',top=' + top
              );

        newwindow=window.open('<?=$loginFbUrl?>','Login_by_facebook',features);

       if (window.focus) {newwindow.focus()}
      return false;

    }

    <?php } ?>

</script>

请帮忙谢谢

4

1 回答 1

0

找到了解决方案:

    <?php
<script>
window.opener.location.reload();
window.close();
</script>

return $this->renderText('<script>opener.location = "' . $url . '";window.close();     </script>'); 
?>
于 2013-09-19T14:09:18.893 回答