Facebook 点赞:未捕获类型错误:对象 # 没有方法“提供”

2024-03-25

我最近添加了 facebook like 按钮,但以下代码在 chrome 中返回错误: Uncaught TypeError: Object # has no method '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 -->

点赞按钮可以使用,但错误很烦人,有人知道如何解决这个问题吗?

Thanks


我最近尝试注射时遇到了同样的问题http://connect.facebook.net/en_US/all.js http://connect.facebook.net/en_US/all.js进入 Google Reader(参加这个激动人心的 Kynetx 编码竞赛:http://code.kynetx.com/2011/04/26/250-to-build-kynetx-facebook-send-within-24hrs-ends-apr-27th/ 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 中的代码从未被执行。我使用的技巧是在包含“之前将 FB 设置为 nullhttp://http://connect.facebook.net/en_US/all.js http://http://connect.facebook.net/en_US/all.js” 。Google Reader 没有抱怨。这可能也是适合您情况的解决方案。 更新:您可能需要这样将 FB 设置为 null:

var head = $("head").get(0);  // using jquery
var script2 = document.createElement("script");
script2.innerHTML = "window.FB = null;FB=null;";
head.appendChild(script2);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Facebook 点赞:未捕获类型错误:对象 # 没有方法“提供” 的相关文章

随机推荐