I had a STAPI-customized button working on my site, but once I added a second one, only the first one works. Is there a limit on the number of calls to the button creation script? When I remove one or the other, the remaining works as required. Thanks!
ShareThis Forums » Publishers
Multiple share this on one page
(6 posts)-
Posted 4 months ago #
-
Hello,
Insert the code you've acquired from the publisher configuration tool into the <head> of the document and use SHARETHIS.addEntry call to generate ShareThis buttons. For more information on the ShareThis API see http://sharethis.com/publisher/type=stapi and http://support.sharethis.com/developers
Posted 4 months ago # -
I already did that. The JS is in the header and this code is on the page twice:
<script language="javascript" type="text/javascript">
//Create your sharelet with desired properties and set button element to false
var object = SHARETHIS.addEntry({
title:'Reclaiming the American Right',
icon: 'http://antiwar.com/antiwar_logo.gif',
url: 'http://antiwar.com/justin//?articleid=12929'
},
{button:false});
//Output your customized button
document.write('<span id="share"> Email this</span>');
//Tie customized button to ShareThis button functionality.
var element = document.getElementById("share");
object.attachButton(element);
</script>
This only works once on a page.Posted 4 months ago # -
Ah, my mistake. I misunderstood the problem. You should be able to reuse part of this script, but you'd need to create a new object for each button that will have different shareable content. Eg.
<script language="javascript" type="text/javascript">
var object2 = SHARETHIS.addEntry({
title:'New Title',
icon: 'New Icon',
url: 'New URL'
},
{button:false});
document.write('span id="share2">Email this</span>');
var element2 = document.getElementByID("share2");
object2.attachButton(element2);
</script>Posted 4 months ago # -
Awesome, worked. I had tried adding "2" to all the objects/vars, but didn't do so for the 'span' id. You should add this issue to your FAQ. Thanks for the help!
Posted 4 months ago # -
Will do and glad you got it to work. =)
Posted 4 months ago #
Reply
You must log in to post.
