Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9001777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:28:54+00:00 2026-06-16T00:28:54+00:00

i want to make my facebook api login popup to close after user logs

  • 0

i want to make my facebook api login popup to close after user logs in, after user clicks the login with facebook image, popup opens succesfully and after user logs in the popup window, the popup still remains there and redirects to my website logged in succesfully, however, i want the popup closed after user logs in succesfully, and redirect the parent login page to main page.

Thank You,

Here is what i did :

Javascript Ones :

<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
    appId      : '<?php echo $_setting['facebook_api']; ?>',
    channelUrl : '//<?php echo $website; ?>/channel.html',
    status     : true,
    cookie     : true,
    xfbml      : true
});
 };



    (function(d) {
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
    }(document));
    </script>
<script type="text/javascript">

function popup(url)
{

 var width  = 600;
 var height = 400;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;

 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=no';
 params += ', status=no';
 params += ', toolbar=no';

 newwin=window.open(url,'FB', params);
 opener.location.reload();
 if (window.focus) {newwin.focus()}

 return false;

 }

 </script>

The User Login Part :

<a href="javascript:void(0)"
onclick="popup('https://www.facebook.com/dialog/oauth?client_id=<?php echo $_setting['facebook_api']; ?>
&redirect_uri=<?php echo urlencode($website."/index.php"); ?>
&cancel_url=<?php echo urlencode($website."/register"); ?>
&scope=email')">
<img src="<?php echo $website; ?>/images/fb.png" /></a>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:28:54+00:00Added an answer on June 16, 2026 at 12:28 am

    Simply output “window.parent.location =”www.pageafterlogin”; window.close();” in the child window didn’t work for me. I had to use an interval to check if the child window (popup) has been closed.

    This is the functions I wrote to make it work (my login button is an anchor with a class set to “facebook_connect”):

    $(document).ready(function() {
        initFacebookConnect();
    });
    
    var fbTimer, fbChildWindow;
    function fbPolling() {
        if(fbChildWindow && fbChildWindow.closed) {
            // The popup has been closed, stop the timer and reload window.
            clearInterval(fbTimer);
            window.location.href = window.location.href;
        }
    }
    function initFacebookConnect() {
        $('a.facebook_connect').click(function(event) {
            event.preventDefault();
    
            var url = $(this).attr('href');
            fbChildWindow = window.open(url, 'Facebook', 'status=1, resizable=0');
            fbTimer = setInterval('fbPolling()', 1000);
        });
    }
    

    Inside the page Facebook redirects to (the redirect_uri page), I write:

    <script>window.close();</script>
    

    I hope this is useful for someone 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want make a wall post on friend wall using facebook graph api. Everything
as described in http://developers.facebook.com/docs/api#publishing i want to make a post request to update a
I want to upload an image to my friend's account/wall using Facebook Api Through
I have a problem. I want to use the facebook api and make a
I want make interactive application where user launches it and can do various task
I am building a user generated content sharing theme and I want to make
I want to make further use of the API by obtaining the list of
I want to make a script that lets me post to my facebook fan
I want to imblement facebook into my app, and I downloaded the FBConnect API,
I know that on a Facebook fan page, if you want to make a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.