Fancybox 具有“共享”功能链接到独特图像的按钮

发布于 2025-01-04 16:33:45 字数 820 浏览 2 评论 0原文

我想在 Fancybox 弹出窗口中显示一个类似 facebook 的按钮。

我想象的交互类似于 Pinterest 在模式弹出窗口右侧显示社交共享按钮的方式(例如 http://pinterest.com/pin/73465037641354472/)。每个图像都有一个唯一的 URL,以便您可以直接链接到弹出窗口的内容。

我如何:

  1. 确保 Fancybox 库中的每个图像都附加到唯一的 URL
  2. 在链接到该唯一 URL 的弹出窗口中显示“赞”按钮

对于 #1,我发现以下页面中讨论了以下代码: fancybox 内的 this.id

$("a.fancybox").each(function() {
  var element = this;
  $(this).fancybox({
    'titleFormat'   : function() {
      var astring = '<span>' + element.id + '</span>';
      return astring;
     }
  });
});

这是我需要的代码吗?如果是这样,我应该在 HTML 中做什么才能让 JavaScript 正常工作?

非常感谢您的帮助!

I would like to display a facebook-like button within the Fancybox popup.

The interaction I'm imagining is similar to how Pinterest displays the social sharing buttons to the right of a modal popup (e.g. http://pinterest.com/pin/73465037641354472/). Each image has a unique url so that you can link to the content of the popup directly.

How can I:

  1. Ensure that each image within my Fancybox gallery is attached to a unique URL
  2. Display a Like button in the popup linked to that unique URL

For #1, I found the following code discussed in the following page: this.id inside of fancybox

$("a.fancybox").each(function() {
  var element = this;
  $(this).fancybox({
    'titleFormat'   : function() {
      var astring = '<span>' + element.id + '</span>';
      return astring;
     }
  });
});

Is this the code that I need? If so, what do I do in the HTML in order for this JavaScript to work properly?

Thanks so much for any help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

呆° 2025-01-11 16:33:47

您需要有一种基于唯一 URL 的机制来提供正确的 http://ogp.me og:由 Facebook 的 linter 解析的元标记。

请记住,linter 不运行 javascript,因此需要在响应流中正确定义它们。

编辑

每个图像都有自己的 URL 的示例。这些将有助于 Facebook 获得正确的 html 和 og: 标签。

http://example.com/images.php?id=1
http://example.com/images.php?id=2
http://example.com/images.php?id=3

在来自每个唯一 URL 的 HTML 响应中,指定了正确的 og: 标记。在该 HTML 中,您应该有一个 javascript 重定向到实际页面以显示图片。由于 linter 不会运行 javascript,因此 linter 应该能够读取这些 og: 标签。

请参阅 http://ogp.me 了解如何指定 og 标签。

You will need to have a mechanism that based upon a unique URL to serve off the correct http://ogp.me og: meta tags to be parsed by Facebook's linter.

Remember the linter does not run javascript, so they will need to be correctly defined in the response stream.

EDIT

Example of each image having it's own URL. These will aid in Facebook being able to get the correct html and og: tags.

http://example.com/images.php?id=1
http://example.com/images.php?id=2
http://example.com/images.php?id=3

Within the HTML response from each of those unique URLs, the correct og: tags are specified. Within that HTML you should have a javascript redirect to the actual page to display the picture. Since javascript wont be run by the linter, the linter should be able to read those og: tags.

See http://ogp.me for how to specify og tags.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文