title: Facebook login onClick - Javascript
body: <p>I have this code on my website. The facebook login dialog is being shown when my page has loaded and not when the user has click on an anchor tag. </p>
  
  <pre><code>&lt;script&gt;
    // Additional JS functions here
    window.fbAsyncInit = function() {
      FB.init({
        appId      : 'xxxxxxxxxxxxxx', // App ID
        channelUrl : '//192.168.1.127/test/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
        } else if (response.status === 'not_authorized') {
          // not_authorized
          login();
        } else {
          // not_logged_in
         login();
        }
      });
    };
  
    function login() {
      FB.login(function(response) {
        if (response.authResponse) {
          testAPI() ;
        } else {
          // cancelled
        }
      });
    }
  
    function testAPI() {
      console.log('Welcome!  Fetching your information.... ');
      FB.api('/me', function(response) {
        console.log('Good to see you, ' + response.name + '.');
      });
    }
  
    // 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));
  &lt;/script&gt;
  </code></pre>
  
  <p>I want the <code>FB.getLoginStatus</code> event to be fired up whenever the user click on this:</p>
  
  <pre><code>&lt;a href = "#" onClick = "FB.getLoginStatus()"&gt;Login&lt;/a&gt;
  </code></pre>
  
  <p>But right now it's being loaded without me doing anythings. </p>
  
  <p>Suggestions?</p>