【发布时间】:2025-12-16 10:20:07
【问题描述】:
您好,我知道已经有人问了很多关于这个问题的问题,但我找不到可以帮助我的答案。
我所拥有的是一个网页,其中包含许多画廊,这些画廊正在使用 fancybox 来显示大图片。我想要的是将 twitter 和 facebook 之类的按钮添加到图片的 fancybox 叠加层中。
这是页面:http://studiovsf.nl/portretten-voorbeelden.html
我首先使用 JSFiddle 进行了尝试,一切正常 (http://jsfiddle.net/kmLWf/247/)
html:
<a class="fancybox" title=" " data-fancybox-group="gallery1" href="http://www.studiovsf.nl/portfolio/portretten/carmen_1.jpg">using text iso image since i have not enough reputations</a><br/>
javascript:
$(".fancybox")
.fancybox({
beforeShow: function () {
// Add tweet button
this.title = '<a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-url="' + this.href + '">Tweet</a> ';
// Add FaceBook like button
this.title += '<iframe src="//www.facebook.com/plugins/like.php?href=' + this.href + '&layout=button_count&show_faces=true&width=500&action=like&font&colorscheme=light&height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:110px; height:23px;" allowTransparency="true"></iframe>';
},
afterShow: function () {
// Render tweet button
twttr.widgets.load();
},
helpers: {
title: {
type: 'inside'
}
}
});
但是当我将此代码放入我的网页时,只显示 twitter 图标,facebook like 按钮不见了。
我似乎无法弄清楚为什么。
如果有人能告诉我我做错了什么,我会非常感激。
谢谢, 鲁本。
【问题讨论】:
标签: javascript jquery facebook fancybox