javascript 将自定义 URL 与 ShareThis 社交分享插件一起使用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12646544/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Use a custom URL with ShareThis social share plugin
提问by max
i would like to know how to use a custom URL with ShareThis social share plugin. for a example i have a post summery on my index.php page taht is linking to my-post.php so what i want to do is to make users share my-post.php from my index page.
我想知道如何在 ShareThis 社交分享插件中使用自定义 URL。例如,我在我的 index.php 页面上有一个 postsumary,它链接到 my-post.php,所以我想要做的是让用户从我的索引页面共享 my-post.php。
here is the code from sharethis.com
这是来自 sharethis.com 的代码
Buttons:
纽扣:
<span class='st_facebook_hcount' displayText='Facebook'></span>
<span class='st_twitter_hcount' displayText='Tweet'></span>
<span class='st_googleplus_hcount' displayText='Google +'></span>
<span class='st_pinterest_hcount' displayText='Pinterest'></span>
JS:
JS:
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">stLight.options({publisher: "ur-448a73fe-e6c1-f7a5-f0a5-3912c860fc9e"});</script>
回答by Mike
You can append a st_url property to each of your span tags which will control the URL that is shared.
您可以将 st_url 属性附加到每个 span 标签,这将控制共享的 URL。
<span class='st_facebook_hcount' st_url='http://my.custom.com/url' displayText='Facebook'></span>
来源:https: //support.sharethis.com/hc/en-us/articles/218441477-How-to-Customize-which-URL-Text-and-IMG-to-Share
回答by Develoger
Just use st_url attribute like this:
只需像这样使用 st_url 属性:
<span class="st_sharethis" st_url="http://www.yoursite.com/innerpage.php" st_title="inner page title" displayText="ShareThis"></span>
回答by Aravind Reddy
You can just add an extra atrribute like
你可以添加一个额外的属性,比如
<div class="sharethis-inline-share-buttons" data-url="<!--YOUR_URL_GOES_HERE-->"></div>