Creating a custom “Share on Facebook” button

At the present date you are unlikely to come across any content page that does not provide option to save the URL in Social Bookmarking sites or Social Networking sites. As a developer adding these functionalities is easy as there are a number of free widgets available that can be added without a lot of fuss. Further, these widgets usually contain a collection of social bookmarking buttons. However, there may be instances when you want a few social bookmark buttons only but the gadget you are using does not contain the particular bookmark button. Recently, I needed to customize my social bookmark buttons gadget to include Facebook button which it originally didn’t.

So here is a short tip on how to add “Share on Facebook” button and also customize popular social bookmarking widgets. Since all Social Bookmarking and Social Networking sites offer more or less the same mechanism this tip gives you a general overview on how your content is shared on Social Web.

function fbs_click()
{u=location.href;t=document.title;window.open
('http://www.facebook.com/sharer.php?u='+
encodeURIComponent(u)+'&t='+encodeURIComponent(t),
'sharer','toolbar=0,status=0,width=6
26,height=436');return false;}
 

The problem I faced with the above approach is that I wanted to modify a widget to add Facebook share in place of another button, say the button associated with furl. But in this case we are creating a separate share on Facebook button and not modifying the widget. So we will take a look at the alternative technique.

From the above snippet we know that we have to access Facebook Web API to share  the link on it. So what I would do is display a facebook icon and pass the URL I want to save to http://www.facebook.com/share.php?

150 150 Burnignorance | Where Minds Meet And Sparks Fly!