facebook登录状态不适用于onclick事件

时间:2013-08-30 20:20:56

标签: javascript jquery facebook facebook-graph-api facebook-javascript-sdk

我试图通过facebook js sdk获取用户登录状态。在没有任何onclick事件的情况下加载脚本时脚本工作正常。但是当我尝试通过触发onclick来执行js时,<div id="fb-root"></div>只会更新,但是不会弹出警告。

function upload() {
  function fbLoginStatus(response) {
     if( response.status === 'connected' ) {
        alert("Connected");
     } else if( response.status === 'not_authorized') {
        $('#overlay-shadow').fadeIn(500);
$('#overlay-container').fadeIn(650);
$('#scriptolution-soft-language.scriptolution-soft-box .content').html('<a href="javascript:void(0);" onclick="collapseAll();" 

class="close-btn badge-language-close"></a><h3>Something is wrong !</h3><br/><h4>Our system got confused. Please try the "Download Cover" 

option. Sorry.</h4>');
     } else {
        alert("Logged Out");
     }
  }

  window.fbAsyncInit = function() {
    FB.init({appId: '414212035337190', status: true, cookie: true, xfbml: true});
    FB.getLoginStatus(fbLoginStatus);
    FB.Event.subscribe('auth.statusChange', fbLoginStatus);
  };
  (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);
  }());
}

0 个答案:

没有答案