jquery - How to show Facebook comments using JavaScript? - Stack Overflow

I want to add Facebook ments using JavaScript (jQuery) to be able to customise the data-href. I used th

I want to add Facebook ments using JavaScript (jQuery) to be able to customise the data-href. I used the following code, but nothing appear in the div col2.

$("#col2").html(
    id+"<div class='fb-ments' data-href='http://127.0.0.1/GazaPlaces/' data-num-posts='2'"+
    " data-width='500'></div>"
);

What is the solution?

I want to add Facebook ments using JavaScript (jQuery) to be able to customise the data-href. I used the following code, but nothing appear in the div col2.

$("#col2").html(
    id+"<div class='fb-ments' data-href='http://127.0.0.1/GazaPlaces/' data-num-posts='2'"+
    " data-width='500'></div>"
);

What is the solution?

Share Improve this question edited Aug 26, 2012 at 20:10 Peter Mortensen 31.6k22 gold badges110 silver badges133 bronze badges asked Feb 17, 2012 at 17:11 BaderBader 3,7749 gold badges40 silver badges55 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

Use the Facebook JavaScript SDK:

<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/en_US/all.js#xfbml=1&appId=75803274170";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>

If you already loaded it, and you then want to add another ments plugin, that is you dynamically added that div in your code, then you need to call the XFBML parse method:

FB.XFBML.parse();
or
FB.XFBML.parse($(id));

You can read more about it in FB.XFBML.parse.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745004107a4605671.html

相关推荐

  • jquery - How to show Facebook comments using JavaScript? - Stack Overflow

    I want to add Facebook ments using JavaScript (jQuery) to be able to customise the data-href. I used th

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信