我有一个没有 SDK 的 facebook 按钮:
<fb:like href="<%= @canonical_url %>" send="" layout="button_count"></fb:like>
<div id="fb-root"> </div>
<script>
// facebook recommend button
window.fbAsyncInit = function() {
FB.init({appId: 'myappid', status: true, cookie: true, xfbml: true});
};
(function() {
// delay to simulate slow loading of Facebook library - remove this setTimeout!!
var t = setTimeout(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/<%= locale_og_tag %>/all.js';
document.getElementById('fb-root').appendChild(e);
}, 0);
}());
</script>
</div>
当我更改页面时,我不会重新加载 facebook 按钮,然后在我的 javascript 文件中运行:
if (typeof (FB) != 'undefined') {
FB.init({ status: true, cookie: true, xfbml: true });
} else {
$.getScript("http://connect.facebook.net/en_US/all.js#xfbml=1", function () {
FB.init({ status: true, cookie: true, xfbml: true });
});
}
但我进入控制台:
FB.init has already been called - this could indicate a problem
我该如何解决这个问题?
谢谢!