href javascript按钮未显示



我正在javascript中实现一个共享函数。但按钮链接没有出现,我真的是一个初学者,经过研究,但我找不到我错在哪里,按钮链接就是没有出现,在我的控制台上没有错误日志。如果有人能帮助我,我真的很失落,我很感激。

在打开这个问题之前,我看到了所有与同一个问题相关的问题,但在我的案例中没有一个是成功的。

$(document).ready(function() {
function sharefbimage() {
FB.init({ appId: `XXXXXX`, status: true, cookie: true });
FB.ui(
{
method: `share`,
name: 'Facebook Dialogs',
href: $(location).attr('href'),
link: 'https://developers.facebook.com/docs/dialogs/',
picture: 'your image url',
caption: 'Ishelf Book',
description: 'your description'
},
function (response) {
if (response && response.post_id) {
alert('success');
} else {
alert('error');
}
}
)};
$(".result").on("click", function() {

var id = $(this).attr("data-linkId");
var url = $(this).attr("href");
if(!id) {
alert("data-linkId attribute not found");
}
increaseLinkClicks(id, url);
return false;
});

var grid = $(".imageResults");
grid.on("layoutComplete", function() {
$(".gridItem img").css("visibility", "visible");
});
grid.masonry({
itemSelector: ".gridItem",
columnWidth: 200,
gutter: 5,
isInitLayout: false
});

$("[data-fancybox]").fancybox({
caption : function( instance, item ) {
var caption = $(this).data('caption') || '';
var siteUrl = $(this).data('siteurl') || '';
var sharefbimage = $(this).data('siteurl') || '';
if ( item.type === 'image' ) {
caption = (caption.length ? caption + '<br />' : '')
+ '<a href="' + item.src + '">View image</a><br>'
+ '<a href="' + siteUrl + '">Visit page</a>';
+ '<a href="' + sharefbimage + '">share</a>';
}
return caption;
},
afterShow : function( instance, item ) {
increaseImageClicks(item.src);
}

});

试试这个。

if ( item.type === 'image' ) {
caption = (caption.length ? caption + '<br />' : '')
+ '<a href="' + item.src + '">View image</a><br>'
+ '<a href="' + siteUrl + '">Visit page</a><br>'
+ '<a href="' + sharefbimage + '">Share</a>';
}

最新更新