我一直用这个:如何检测Facebook javascript功能何时准备好?
function FB_wait() {
if (typeof FB == 'undefined') {
window.setTimeout(FB_wait, 100);
} else {
more();
}
}
但是,必须有一个更好的办法
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo $conf['fb']['appid']; ?>',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Canvas.setAutoResize();
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
这是我的初始化代码..
您是否异步加载FB的脚本? – Anurag 2010-08-22 23:44:59
是的..我已经包含代码:) – Pablo 2010-08-23 14:10:07