动态facebook喜欢fancybox v2中的按钮

时间:2012-05-30 09:47:31

标签: jquery fancybox-2

动态facebook喜欢fancybox v2中的按钮

如何制作类似fb的fancybox v2,如图片标题后的tweet.G +按钮, 这是我的代码。我会为每个图像制作不同的buutons。

$('.fancybox-buttons').fancybox({
    openEffect: 'none',
    closeEffect: 'none',
    prevEffect: 'none',
    nextEffect: 'none',
    playSpeed: 2500,
    arrows: false,
    nextClick: true,
    helpers: {
        thumbs: {
            width: 50,
            height: 50
        },
        buttons: {}
    },
    afterLoad: function ()
    {
        this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
    }
});

1 个答案:

答案 0 :(得分:1)

这不会完全回答你的问题,但请看看这篇文章,为你的Fancybox添加一个Facebook赞按钮。 Facebook like button not displaying in FancyBox?

您需要在fancybox中为每个项目(照片?)提供自己的网址。因此,如果您有照片,请确保每张照片都可以通过http://yourdomain.com/photo/photo_name_1http://yourdomain.com/photo/photo_name_2等网址获取...

当您创建类似Facebook的按钮时,请确保取消选择“发送按钮”,然后您可以选择iFrame。将“URL to Like”设置为站点的基本域,以便在创建按钮时创建占位符。你的iFrame最终会是这样的:

<iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fyourdomain.com%2F&amp;send=false&amp;layout=button_count&amp;width=450&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font=verdana&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe>

在iFrame中,您可以看到传递回Facebook的链接。它以http开头,然后是冒号:(%3A)和斜杠/(%2F)。如果你想为每个图像添加一个单独的按钮,请在代码中动态地将其余的url附加到你的按钮(使用PHP,Ruby,javascript,等等......)来创建这样的东西 ... HTTP%3A%2F%2Fyourdomain.com%2Fphoto%2Fphoto_name_1