简体   繁体   English

Facebook 分享按钮

[英]Facebook share button

I want to add Facebook share button to my site.我想在我的网站上添加 Facebook 分享按钮。 But when I use the code given by Facebook, it doesn't show any FB logo image in button style & also doesn't count any share.但是当我使用 Facebook 提供的代码时,它不会以按钮样式显示任何 FB 徽标图像,也不计算任何份额。 Please help me figure out a better code.请帮我找出更好的代码。

Currently, I'm using:目前,我正在使用:

   <a href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fparse.com" target="_blank">
  Share on Facebook
</a>

The easiest way to add Facebook share button would be to visit http://www.facebook.com/share_partners.php and copy the code and paste it in your webpage after replacing the text "url" with the actual URL of the page you want to share.添加 Facebook 共享按钮的最简单方法是访问http://www.facebook.com/share_partners.php并复制代码并将其粘贴到您的网页中,然后将文本“url”替换为您的页面的实际 URL想分享。 If it is dynamic content, you can use the variable or object name.如果是动态内容,可以使用变量名或对象名。

 <script>
function fbs_click(){
u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
return false;
}
</script>
<a href="http://www.facebook.com/share.php?u=<url>" onclick="return fbs_click()" target="_blank"> <img src= "http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981" alt="" /></a>

Take a look at the official documentation: Facebook For Developers: Share Button .看看官方文档: Facebook For Developers: Share Button

If you merely click the "Get Code" option on the Facebook Share Button Configurator & Generator , you'll see that the URL generated is rather simple:如果您仅单击Facebook Share Button Configurator & Generator上的“获取代码”选项,您将看到生成的 URL 非常简单:

https://www.facebook.com/sharer/sharer.php?u= {yourURLhere} https://www.facebook.com/sharer/sharer.php?u= {yourURLhere}

At least it seems that way to me:至少在我看来是这样:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM