简体   繁体   中英

Facebook Share button and comment plugin conflict

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?

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/

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM