title: Facebook API login -logging
body: <p>I was looking at logging all the users that entered the website using FB .with the help of purushotam ( see my other question)  was able to proceed.</p>
  
  <p>here are my new issues:
  1) how can I get/use the facebook provided button. Reason is I want user to get the same user experience. (facebook button bluish button)
  2) once the user logs in than , I want to send a alert and than go to the website I re-directed (in example I have stackoverflow).  Because FB is non blocking asynchronous, I see before the FB returns the value the website is getting redirected. how to resolve this issue.
  3) When a user tries to login I dont want the FB popup- I want to have the FB login in a new page (just like stackoverflow login) how can I do that ..</p>
  
  <pre><code>  &lt;body&gt;
          &lt;div id="fb-root"&gt;&lt;/div&gt;
  &lt;script&gt;
  
        window.fbAsyncInit = function() {
            FB.init({appId: 'xxxx', status: true, cookie: true, xfbml: true});
  
        };
        (function() {
          var e = document.createElement('script'); e.async = true;
          e.src = document.location.protocol +
            '//connect.facebook.net/en_US/all.js';
          document.getElementById('fb-root').appendChild(e);
        }());
  
      function fetchUserDetail()
      {
          FB.api('/me', function(response) {
                  alert("Name: "+ response.name + "\nFirst name: "+ response.first_name + "ID: "+response.id);
              });
          window.location.href = 'http://www.stackoverflow.com';  
      }
  
      function checkFacebookLogin() 
      {
          FB.getLoginStatus(function(response) {
            if (response.status === 'connected') {
              fetchUserDetail();
            } 
            else 
            {
              initiateFBLogin();
            }
           });
      }
  
      function initiateFBLogin()
      {
          FB.login(function(response) {
             fetchUserDetail();
           });
      }
      &lt;/script&gt;
  
  
   &lt;input type="button" value="Sign in using Facebook" onclick="checkFacebookLogin();"/&gt;
  
  
  &lt;/body&gt;
  </code></pre>