Add facebook comments inside a 'lightbox'

亡梦爱人 提交于 2019-12-24 08:47:47

问题


I am building a website to showcase some photos. The photos are viewed using a lightbox like effect. I want to add facebook comments inside the 'lightbox' but the comments doesn't load.

$(function() {

    $('.pics').click(function(){

         ...
         ...

         $(".comments").html("<div id=\"fb-root\"></div><script src=\"http://connect.facebook.net/en_US/all.js#xfbml=1\">" + "<" + "/" + "script>" + "<fb:comments href=\"example.com\" num_posts=\"5\" width=\"800\"></fb:comments>");

          }); 

    });

Thanks in advance.


回答1:


I think you should try rendering the comments first but keep them invisible. Something like:

<div id="comments" class="hidden">      
  <fb:comments href="example.com" num_posts="5" width="800"></fb:comments>
</div>

Assume the hidden class makes the div invisible.

Now with JavaScript code you should be able to do this:

$(".pics").click(function(){
    $("#comments").show();
});

I have not tested this yet and there's an off-chance Facebook won't load the comments into an invisible element. If that's the case, you might be able to get away with rendering it and adding the hidden class after the page loads, though there might be a flicker.




回答2:


I think you should try this one http://www.zemgo.net23.net/lightbox.html



来源:https://stackoverflow.com/questions/6179569/add-facebook-comments-inside-a-lightbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!