按照該FB.Event.subscribe,還有它會自動在頁面將完成渲染插件
觸發加載事件
第1步:在HTML(把它放在你想要的社會盒被示出):
<div class="fb-page" data-href="https://www.facebook.com/facebook" data-small-header="true" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true"><div class="fb-xfbml-parse-ignore"><blockquote cite="https://www.facebook.com/facebook"><a href="https://www.facebook.com/facebook">Facebook</a></blockquote></div></div>
步驟2:在頁腳(結束<body>
標籤之前):
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function(){
//FB.init({ status: false, cookie: true, xfbml: true });
FB.Event.subscribe("xfbml.render", function(){
SocialBoxesLoaded(); //-->this is what we want (any custom Function) :)
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function SocialBoxesLoaded(){
//...Your Custom Code...
}
</script>
是的,它添加訂閱後,效果很好,謝謝! –
也爲我工作。如果你想看到我的工作代碼示例,請看這裏:http://stackoverflow.com/questions/5449193/facebook-like-box-load-event-jquery/19295464#19295464 – Tillito