简体   繁体   English

在“灯箱”中添加 facebook 评论

[英]Add facebook comments inside a 'lightbox'

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.我想在“灯箱”中添加 facebook 评论,但没有加载评论。

$(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.提前致谢。

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.假设隐藏的 class 使div不可见。

Now with JavaScript code you should be able to do this:现在使用 JavaScript 代码,您应该能够做到这一点:

$(".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.我还没有对此进行测试,并且很有可能 Facebook 不会将评论加载到不可见的元素中。 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.如果是这种情况,您可能可以在页面加载后渲染它并添加hidden的 class ,尽管可能会出现闪烁。

I think you should try this one http://www.zemgo.net23.net/lightbox.html我想你应该试试这个http://www.zemgo.net23.net/lightbox.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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