2012-09-03 90 views
1

當我從任何Facebook社交插件(如評論框或類似按鈕)登錄或註銷時,是否有任何方法捕獲Facebook事件?我想在用戶登錄到Facebook插件時刷新我的頁面。因爲當我用評論框登錄時,它不顯示我已登錄,所以我不能使用「贊」按鈕。但是當我刷新我的頁面時,它顯示我已登錄到兩個插件。當我從Facebook註釋框登錄/註銷時,如何捕獲事件?

這裏是我的代碼:

<div id="fb-root"> 
</div> 
<script> 
    window.fbAsyncInit = function() { 
     FB.init({ appId: 'My App ID', status: true, cookie: true, xfbml: false }); 

     setTimeout(aaa, 6000); 

     FB.Event.subscribe("xfbml.render", function (targetUrl) { 
      $("#myh1").html("Facebook Loaded"); 
      alert('edge.create'); 
     }); 


     FB.Event.subscribe('auth.authResponseChange', function (response) { 
      alert('The status of the session is: ' + response.status); 
     }); 
    }; 
    (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 aaa() { 
     FB.XFBML.parse(document.getElementById('fbDiv'), function() { 
      alert('I rendered'); 
     }); 
    } 
</script> 

<div id="fbDiv"> 
    <div class="fb-comments" data-href="http://www.facebook.com/AiLiveCaptions" data-num-posts="2" data-width="470"> 
    </div> 
</div> 

回答

0

我看到它的方式,這可能是當你使用兩個單獨的插件度過他們的Facebook或任何第三方網站i.e.facepile/commentbox的默認行爲。

瀏覽器需要重新加載才能在同一頁上的多個插件上更新頁面上的會話,就像在不同瀏覽器上打開相同標識時在多個選項卡上打開任何郵件ID時的差異一樣。