Friday, December 14, 2007

Adding Dynamic Facebook Bookmarklets To Blogger Posts

If you are not satisfied with having just a Digg link on your blog posts, why not add a Facebook bookmarlet?

Here is the code you need (don not let the HTML entities scare you - copy this exactly):
<script>
function fbs_click()
{
u=<data:post.url/>;
t=<data:post.title/>;
window.open(&#39;http://www.facebook.com/sharer.php?u=&#39;+encodeURIComponent(u)+&#39;&amp;t=&#39;+encodeURIComponent(t),&#39;sharer&#39;,&#39;toolbar=0,status=0,width=626,height=436&#39;);
return false;
}
</script>
<style>
html .fb_share_link {
padding:2px 0 0 20px;
height:16px;
background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?43:26981) no-repeat top left;
}
</style>
<a class='fb_share_link' expr:href='"http://www.facebook.com/sharer.php?u=" + data:post.url' onclick='return fbs_click()' target='_blank'>Share on Facebook</a>
You will want to add this to or below the footer section of your template's posts includible e.g. after the third footer line.