简体   繁体   English

我可以为 facebook 制作一个分享按钮并将其与特定的 div 链接以进行分享吗?

[英]Can I make a share button for facebook and link it with a specific div to share?

I have a website on WordPress, I do have infoboxes created and would like to give a share button down below each box and link it with the box to share only the contents of the box instead of the whole page.我在 WordPress 上有一个网站,我确实创建了信息框,并希望在每个框下方提供一个共享按钮,并将其与框链接以仅共享框的内容而不是整个页面。 Each div has it's own ID defined however there is no predefined link for each of them.每个 div 都定义了自己的 ID,但是每个 div 都没有预定义的链接。

Any way, I can create a share button and link this infobox with it using the ID to share?无论如何,我可以创建一个共享按钮并使用 ID 将这个信息框与它链接起来共享? I want to make these boxes shareable.我想让这些盒子可以共享。

在此处输入图像描述

In facebook documentation to create a share link button it says在 facebook 文档中创建一个共享链接按钮它说

Pick the URL of a website or Facebook Page you want to share.选择您要分享的网站的 URL 或 Facebook 页面。

https://developers.facebook.com/docs/plugins/share-button/?locale=en_US https://developers.facebook.com/docs/plugins/share-button/?locale=en_US

So if you want to share something you must have a link to share.所以如果你想分享一些东西,你必须有一个分享链接。

You can create a specific page about your infoboxes and share the link of your-website/the-infobox.您可以创建有关您的信息框的特定页面并共享您的网站/信息框的链接。

If you manage to make a link your code for the share button will look like this如果您设法创建链接,则共享按钮的代码将如下所示

<iframe src="https://www.facebook.com/plugins/share_button.php?href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&layout=button_count&size=small&width=96&height=20&appId" width="96" height="20" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowfullscreen="true" allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share"></iframe>

Or或者

<div id="fb-root"></div>
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v10.0" nonce="qXOmpYBu"></script>

<div class="fb-share-button" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button_count" data-size="small">
    <a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&amp;src=sdkpreparse" class="fb-xfbml-parse-ignore">Share</a>
</div>

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

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