Facebook like:Uncaught TypeError:Object#< an Object>没有方法'提供' [英] Facebook like : Uncaught TypeError: Object #<an Object> has no method 'provide'

查看:143
本文介绍了Facebook like:Uncaught TypeError:Object#< an Object>没有方法'提供'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近添加了像Facebook这样的按钮,但以下代码在chrome中返回错误:未捕获TypeError:Object#没有方法'提供'

 <! -  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 - >

类似的按钮可以正常工作,但是错误是懊恼的,有没有人知道如何解决?



谢谢

解决方案

我最近遇到了同样的问题将 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 = {...开头,并声明'提供'方法。在谷歌阅读器中,FB对象已经存在(不知道为什么或如何被创建),所以如果从未被执行的代码。我使用的技巧是将FB设置为null,然后才能包含 http:// http: //connect.facebook.net/en_US/all.js 。 Google Reader没有抱怨。这可能也是您的情况的解决方案。
更新:您可能需要将FB设置为null:

  var head = $(head)获得(0); //使用jquery 
var script2 = document.createElement(script);
script2.innerHTML =window.FB = null; FB = null;;
head.appendChild(script2);


I have recently added the facebook like button, but the following code returns an error in 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 -->

The like button works but the error is anoying, does anyone know how to solve that?

Thanks

解决方案

I recently got the same problem when I tried to inject http://connect.facebook.net/en_US/all.js into Google Reader ( for this exciting Kynetx coding contest : http://code.kynetx.com/2011/04/26/250-to-build-kynetx-facebook-send-within-24hrs-ends-apr-27th/ ) . all.js starts with "if (!window.FB) window.FB = { ..." and declares the 'provide' method . In google reader the FB object was already present (dont know why or how it was created) so the code inside the if never got executed. The trick I used was to set FB to null before including "http://http://connect.facebook.net/en_US/all.js" . Google Reader didn't complain. It might be a solution in your situation too. Update: you may need to set FB to null this way:

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

这篇关于Facebook like:Uncaught TypeError:Object#&lt; an Object&gt;没有方法'提供'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆