【问题标题】:Facebook Like plugin with big buttons?Facebook Like 带有大按钮的插件?
【发布时间】:2014-07-22 16:41:00
【问题描述】:

我需要一个专为 FB 设计的社交媒体插件。我需要 FB 的大分享按钮。我在几个网站上看到过,但不知道是哪一个。

我留下这个链接是为了告诉你我在说什么(文章开头和结尾的大 FB 按钮):

http://www.viralnova.com/animals-eating-ice-cream/

有什么想法吗?

【问题讨论】:

标签: facebook button plugins facebook-like updown


【解决方案1】:

制作大赞(不是赞按钮,这是分享按钮)按钮没有秘诀,这一切都归结为 Facebook 开发人员工具的基本知识...

Facebook 有Sharer,它接受GET 参数u,这是您要在时间轴上、朋友的墙上甚至在私人消息中分享的 URL ...

分解

您可以为您的分享按钮创建一个新元素或包装器,我将只使用<a>,因为它们看起来既快速又易于用于此目的。

<a class="fsl fsl-facebook" data-href="{URL_to_Share}" href="#">
   <span class="fa-facebook fa-icons fa-lg"></span>
   <span class="sc-label">Share on Facebook</span>
</a>

注意data-href 属性,因为您应该将其替换为您要分享的网址

接下来我们需要一些 JavaScript (jQuery) 来让我们的分享按钮做一些事情

$('.fsl-facebook').click(function(e){ // target all elements with fsl-facebook class in the DOM
    e.preventDefault(); // prevent scrolling to top or bottom, because href is set to # 
    var href = $(this).attr('data-href'); // get URL from the data-href 
    window.open('https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(href), "", "width=800, height=350"); // pop up a new window, it's prefered to urlencode the URL because of 2nd & 3rd GET parameter that can be found in some URLs (?a=1&b=2&c=3)
});

DEMO

【讨论】:

  • 非常感谢亚当。我很感激。你是对的,它们是分享按钮。
  • 我还没有时间实现这个,我现在就做。如果我有任何疑问,我会回复您。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-23
  • 1970-01-01
相关资源
最近更新 更多