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 9032111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:53:59+00:00 2026-06-16T07:53:59+00:00

Please help me. I know this is very simple, but my bad luck :(

  • 0

Please help me. I know this is very simple, but my bad luck 🙁

I am trying to implement facebook login with JavaScript SDK in my site by following facebook official docs. When i go to mysite login page, then facebook login window pop up automatically. But i want it after click login button.

The login button:

<p class="fb_login">or <img src="assets/img/fb-login-button.jpg" onClick="FB.login()" onlogin="alert( 'Logged In' );"></p>

Javascript:

window.fbAsyncInit = function() {
    FB.init({
      appId      : '486435991400780', // App ID
      channelUrl : '//http://localhost/ride/assets/channel.html', // Channel File
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });

    // Additional init code here
    FB.getLoginStatus(function(response) {
        if (response.status === 'connected') {
            // connected
            replace_login();
            FB.api('/me', function(response) {
                console.log('Good to see you, ' + response.name + '.');
                alert('Good to see you, ' + response.name + '.');
            });
        } else if (response.status === 'not_authorized') {
            // not_authorized
            login();
        } else {
            // not_logged_in
            login();
        }
    });
  };

  function login() {
      FB.login(function(response) {
          if (response.authResponse) {
              // connected
              window.location.reload();
          } else {
              // cancelled
              alert('User cancelled login or did not fully authorize.');
          }
      });
  }

  function replace_login(){
       FB.api('/me', function(response) {
           $('.fb_login').html('<span class="fb_logged_in">' + response.name + ', You are already logged in with Facebook!</span>');
       });
  }

  // Load the SDK Asynchronously
  (function(d){
       var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
       if (d.getElementById(id)) {return;}
       js = d.createElement('script'); js.id = id; js.async = true;
       js.src = "//connect.facebook.net/en_US/all.js";
       ref.parentNode.insertBefore(js, ref);
   }(document));

on my html:

<div id="fb-root"></div>
<script src="assets/js/fb-login.js" type="text/javascript"></script>

Thanks.

  • 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-16T07:54:01+00:00Added an answer on June 16, 2026 at 7:54 am

    Remove “login()” calls in javascript after the login status is checked, so that the login popup does not come up:

    // Additional init code here
    FB.getLoginStatus(function(response) {
        if (response.status === 'connected') {
            // connected
            replace_login();
            FB.api('/me', function(response) {
                console.log('Good to see you, ' + response.name + '.');
                alert('Good to see you, ' + response.name + '.');
            });
        }
    });
    

    Add a button (styled with CSS ideally):

    <button onclick="login();">Login with Facebook</button>
    

    Note: The button should probably be hidden by the javascript if the user is logged in (or added if not logged in).

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

Sidebar

Related Questions

This may be very simple question,But please help me. i wanted to know what
i know it may be very simple query, but please help me out. i
I know this is a very simple question for you experts,but please forgive me.Im
I know this error appeared on forum million of times, but please help me
I know it sounds very simple, and there are questions about this. But none
i know this is very simple question but i am new on this so
Please, help me. I dont know what is wrong with this code: import android.appwidget.AppWidgetProvider;
Don't know why but font is not displaying.Please help. CSS(in css folder): style.css: @font-face
I am just trying to compile and run a very simple test program, but
I know the post seems long, but I'm sure there's a very simple solution.

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.