繁体   English   中英

st_twitter_hcount和st_fblike_hcount的正确共享类型(通过JS动态指定)

[英]Proper share type for st_twitter_hcount and st_fblike_hcount (Dynamic specification through JS)

这是我的测试页: http : //ignitepixels.com/test/shareThisTest.html

我在用Javascript动态生成ShareThis按钮时遇到问题。 对于我的大多数按钮,我想使用“ chicklet”类型。 但我也想包括Twitter分享hcount和Facebook像hcount按钮。

通常(没有javascript),您将使用类似:

<span class='st_twitter'></span>
<span class='st_facebook'></span>
<span class='st_linkedin'></span>
<span class='st_googleplus'></span>
<span class='st_email'></span>
<span class='st_reddit'></span>
<span class='st_twitter_hcount'></span>
<span class='st_fblike_hcount'></span>

但是我试图使用以下方法动态生成这些按钮:

stWidget.addEntry({
"service" : shareService,
"element" : document.getElementById(shareElemendID),
"url" : shareURL,
"title" : shareTitle,
"type" : shareType,
"onhover" : false
});

(注意:我的shareType var是使用javascript动态生成的。您可以通过查看测试页的源代码来查看javascript。)

我可以将"chicklet"用作"type"的硬值,但这不能正确呈现hcount按钮。 因此,我有一些js决定使用“ chicklet”还是“ hcount”,但是即使hcount也会产生有趣的结果。 (请参见标题“动态ShareThis按钮”下的http://ignitepixels.com/test/shareThisTest.html )。

有人知道我在JavaScript中使用的hcount按钮应该使用哪种类型吗?

谢谢!

对于未来的用户,这是我从ShareThis支持代理那里获得的答案( http://support.sharethis.com/customer/portal/questions/862200-proper-share-type-for-st-twitter-hcount-and-st -fblike-hcount-dynamic-specification-through-js-#sthash.F82qZiuZ.dpbs ):

由于使用了错误的“服务”名称,因此按钮格式错误。 您不能使用此类服务​​名称-“ st_twitter_hcount”

请使用服务名称作为-“ twitter”,“ facebook”,然后可以在“ type”中将按钮类型指定为“ hcount”或“ vcount”。

以下是有关如何使用已实现的代码实现此目的的示例。

shareServices : ['twitter', 'facebook', 'linkedin', 'googleplus', 'email', 'reddit', 'st_twitter', 'st_fblike','st_wordpress','st_linkedin']

shareType = ( shareService.match(/^st_/) ) ? 'hcount' : 'chicklet' ;
if( shareService.match(/^st_/) )
{
    shareService=shareService.substring(3);
};

暂无
暂无

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

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