Facebook喜欢:Uncaught TypeError:Object#<an Object>没有方法'provide'

Roc*_*och 4 javascript facebook

我最近添加了facebook like按钮,但是以下代码在chrome中返回错误:Uncaught TypeError:Object#没有方法'provide'

<!-- Facebook -->
<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({appId: '121814204514513', status: true, cookie: true,
             xfbml: true});
  };
  (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);
  }());
</script>
<!-- Facebook -->
Run Code Online (Sandbox Code Playgroud)

类似的按钮工作,但错误很烦人,有谁知道如何解决?

谢谢

Loi*_*aux 7

当我试图将http://connect.facebook.net/en_US/all.js注入Google阅读器时,我最近遇到了同样的问题(对于这个令人兴奋的Kynetx编码比赛:http://code.kynetx.com/2011/04 / 26/250-to-build-kynetx-facebook-send-within-24hrs-ends-apr-27th /).all.js以"if(!window.FB)window.FB = {..."开头,并声明'provide'方法.在谷歌阅读器中,FB对象已经存在(不知道为什么或如何创建)所以if中的代码从未被执行过.我使用的技巧是在包含" http:// http://connect.facebook.net/en_US/all.js "之前将FB设置为null .谷歌阅读器没有抱怨.它也可能是您的情况的解决方案.更新:您可能需要以这种方式将FB设置为null:

var head = $("head").get(0);  // using jquery
var script2 = document.createElement("script");
script2.innerHTML = "window.FB = null;FB=null;";
head.appendChild(script2);
Run Code Online (Sandbox Code Playgroud)