【发布时间】:2015-02-11 20:31:01
【问题描述】:
这是一个非常非常基本的问题,因为我是 Javascript 和 Jquery 的新手,但我似乎无法在任何地方找到答案。
我正在尝试在我们网站的一个页面上实现 FancyBox,包括 FancyBox 提示和技巧提供的其他社交分享按钮。
这是我到目前为止所做的(还没有社交分享),我喜欢它: http://www.aatg.org/default.asp?page=Testpageja
问题是我不知道在哪里将社交分享按钮的代码添加到提供的 jquery.fancybox.js 文件中。我太新了,无法弄清楚函数应该在哪里。我已经在 JSFiddle 中找到了它,所以它可以工作,我只是不知道现在把它放在我的网站上的哪里,所以它可以正常工作。
这是我在 JSFiddle 中提出的:http://jsfiddle.net/G5TC3/3186/
$(".fancybox")
.attr('rel', 'gallery')
.fancybox({
beforeShow: function () {
if (this.title) {
// New line
this.title += '<br />';
// 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/share_button.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'
}
}
});
`
谁能帮我告诉我这需要放在 jquery.fancybox.js 文件中的什么地方(可从 Fancybox 下载)。也许我错了,上面的代码需要进入 jquery.fancybox.pack.js? (注意:现在它是一个 FB 分享而不是一个赞按钮,但这就是我想要的)。
非常感谢您帮助菜鸟。
【问题讨论】:
标签: javascript jquery facebook fancybox