我正在使用下面的 jsfiddle 在我的 fancybox 标题上添加社交按钮。我有两个问题
1)当对href使用“this.href”代码时,不会出现like按钮,尽管它适用于jsfiddle。
2)当我使用推文分享按钮时,它会分享我网站的标题,尽管在 jsfiddle 上它显示标题 + 图片 url。是否可以改为显示 IFRAME 标题和 url?(正如您在 jsfiddle 上看到的,我的 fancybox 类型是 iframe)。
JSFIDDLE:http: //jsfiddle.net/kmLWf/44/
$.fancybox.update();
$('.iframe').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/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();
},
href:this.href,
padding:0,
type:'iframe',
scrolling : "no",
prevEffect : 'fade',
nextEffect : 'fade',
preload:true,
autoSize : false,
autoCenter: true,
fitToView : false,
loop: false,
helpers : {
overlay : {
css : {
'background' : 'rgba(0, 0, 0, 0.7)',
'overflow-y': 'hidden'
},
}
}
});