Facebook 分享按钮和评论插件冲突

发布于 2024-12-08 09:50:13 字数 1060 浏览 4 评论 0原文

在我的博客中,我需要实现 Facebook 分享按钮(带有计数器)和评论插件。我刚刚使用了下面的代码。

FACEBOOK SHARE

<a
    name="fb_share"
    type="button_count"
    href="http://www.facebook.com/sharer.php">
    Share
</a>
<script
    src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"
    type="text/javascript">
</script>

FACEBOOK COMMENT PLUGIN

<div id="fb-root"></div>
<script>
    (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/it_IT/all.js#xfbml=1";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-comments" data-href="<?php the_permalink(); ?>" data-num-posts="2" data-width="524"></div>

最后返回错误

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

on line 4,并且此错误不显示评论插件。它显示的是共享按钮。

这个问题有什么解决办法吗?

In my blog I need to implement both a Facebook share button (with a counter) and comment plugin. I just used the code below.

FACEBOOK SHARE

<a
    name="fb_share"
    type="button_count"
    href="http://www.facebook.com/sharer.php">
    Share
</a>
<script
    src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"
    type="text/javascript">
</script>

FACEBOOK COMMENT PLUGIN

<div id="fb-root"></div>
<script>
    (function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/it_IT/all.js#xfbml=1";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-comments" data-href="<?php the_permalink(); ?>" data-num-posts="2" data-width="524"></div>

In the end, it returns the error

Uncaught TypeError: Object # has no method 'provide'

on line 4, and this error don't show the comment plugin. It shows instead the share button.

Is there any solution to this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

柒七 2024-12-15 09:50:13

我遇到了完全相同的问题。我最终不得不切换我正在使用的 FB 插件。

这是我网站的链接,其中包含评论和点赞按钮:
http://www.jhousemedia .com/blog-articles/145/Building-A-Good-Website-For-Your-Business.html

我必须使用 Like/Send 插件切换共享按钮。幸运的是,他们可以选择使其适合与共享按钮类似的形式。
这是使用的插件
http://developers.facebook.com/docs/reference/plugins/like/

I had the exact same problem. I ultimately had to switch which FB plugin I was using.

Here's the link to my site where I have the comments and the like button together:
http://www.jhousemedia.com/blog-articles/145/Building-A-Good-Website-For-Your-Business.html

I had to switch out the share button with the Like/Send plugin. Fortunately, they have an option to make it fit a similar form as the share button.
Here's the plugin used
http://developers.facebook.com/docs/reference/plugins/like/

终难遇 2024-12-15 09:50:13

我不确定,但您可以尝试评论或删除此行:

js.src = "//connect.facebook.net/it_IT/all.js#xfbml=1";

也许共享和评论脚本是重复的代码。

I'm not sure, but you can try to comment or delete this line:

js.src = "//connect.facebook.net/it_IT/all.js#xfbml=1";

Maybe share and comment scripts are duplicating code.

跨年 2024-12-15 09:50:13

通过将注释脚本替换为标题中的这一行来解决此问题

<script src="http://connect.facebook.net/ro_RO/all.js#appId=202676036413585&xfbml=1"></script>

Solved this by replacing the comments script with just this line in the header

<script src="http://connect.facebook.net/ro_RO/all.js#appId=202676036413585&xfbml=1"></script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文