How do I execute my own function along with the ShareThis button?
To tie a custom function to the ShareThis button, you must set the JavaScript element “onclick” to the name of your custom function:
Below is an example of this ShareThis API procedure:
<script language=”javascript” type=”text/javascript”>
//Use a customized callback routine. For example:
function custom(sharelet){
alert(sharelet.properties.title);
//Return true to continue share event
return true;};
//Create a sharelet with button element set to false and the custom handler
var object = SHARETHIS.addEntry({
title:’share’,
summary: ‘Sharing is good for the soul’},
{button:false, onclick:custom};
//Create customized button and attach it to the share object
document.write(‘<span id=”share”><ahref=”javascript:void(0);”>Share!</a></span>’);
var element = document.getElementById(“share”);
object.attachButton(element);
</script>
Popularity: 9%
