触发fb:登录按钮与其他按钮Javascript

时间:2013-07-24 08:27:22

标签: facebook button facebook-javascript-sdk facebook-login

我想触发fb:login-button

<fb:login-button show-faces="true" width="200" max-rows="1"></fb:login-button>

用第二个按钮。为什么?我无法调整Facebook的CSS,我想要一个带有自定义图像的花哨按钮来取代它。我的大问题是我不知道FB按钮的ID是什么,我不能给它一个。

我的错误代码:

<script>
    function Ffirst()
    {
    alert("first");
    $("fb:login-button").click(); 
    //$("fb:login-button").trigger("click"); //doesn't work eiter
    }
</script>

<input type="submit" onclick="Ffirst()" name="savebutton" id="first" />
<fb:login-button show-faces="true" width="200" max-rows="1"></fb:login-button>

FTR: 当我按the fb:login-button

时会发生这种情况
FB.Event.subscribe('auth.authResponseChange', function(response) {
    // Here we specify what we do with the response anytime this event occurs. 
    if (response.status === 'connected') {
          testAPI();
    }

    } else if (response.status === 'not_authorized') {
      FB.login();

    } else {
          FB.login();
    }
  });

  // 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));

1 个答案:

答案 0 :(得分:4)

通过代码中的@Lix回答:

<input type="submit" onclick="FB.login()"/>