Deprecated: Assigning the return value of new by reference is deprecated in /home/gathadam/public_html/wp-settings.php on line 520

Deprecated: Assigning the return value of new by reference is deprecated in /home/gathadam/public_html/wp-settings.php on line 535

Deprecated: Assigning the return value of new by reference is deprecated in /home/gathadam/public_html/wp-settings.php on line 542

Deprecated: Assigning the return value of new by reference is deprecated in /home/gathadam/public_html/wp-settings.php on line 578

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/gathadam/public_html/wp-settings.php on line 18
Build your own Social Bookmark widget
Previous     Next

Build your own Social Bookmark widget

It’s important to make it as easy as possible for your visitors to bookmark your site - both so they can find it again, and also so they can share it with their friends. I have a bunch of sites, and I wanted to create a simple way to add bookmarking to all of them.

Basically, the bookmark links provided by the social networks accept 2 parameters:

  • The URL of the site/post
  • The title of the page

It is easy enough to get both those values using javascript:

var TheTitle = encodeURIComponent(document.title);
var TheURL = encodeURIComponent(document.location);

It is important to encode the values, so that they can safely be placed in a bookmark URL.

You then just need the code to output the bookmark link. Here it is for Google Bookmarks

document.write(’<a href=”http://www.google.com/bookmarks/mark?op=add&bkmk=’ + TheURL + ‘&title=’ + TheTitle + ‘” title=”Bookmark to Google”><img src=”http://img2.imagepile.net/images/ycc2106/35814433.png” alt=”Google” height=”16″ width=”16″ border=”0″ /> Google</a>’);

Add a few other Networks (BlinkList, Furl, Delicious) and the full code is:


var TheTitle = encodeURIComponent(document.title);
var TheURL = encodeURIComponent(document.location);
document.write("<style>a.sbm{padding-left:7px}</style>");
document.write("<div>Bookmark with:");
document.write('<a class="sbm" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&Url='+TheURL+'&Title='+TheTitle+'")title="Add To BlinkList"><img src="http://img2.imagepile.net/images/ycc2106/89442389.png" alt="BlinkList"  height="16" width="16" border="0" /> BlinkList</a>');
document.write('<a class="sbm" href="http://www.furl.net/storeIt.jsp?u='+TheURL+'&t='+TheTitle+'" title="Bookmark To Furl"><img src=http://www.furl.net/i/favicon.gif alt="Furl button"  height="16" width="16" border="0" /> Furl</a>');
document.write('<a class="sbm" href="http://www.google.com/bookmarks/mark?op=add&bkmk='+TheURL+'&title='+TheTitle+'" title="Bookmark to Google"><img src="http://img2.imagepile.net/images/ycc2106/35814433.png" alt="Google"  height="16" width="16" border="0" /> Google</a>');
document.write('<a class="sbm" href="http://del.icio.us/post?url='+TheURL+'&title='+TheTitle+'" title="See who bookmarked at del.icio.us" ><img src="http://img2.imagepile.net/images/ycc2106/65682475.png" alt="del.icio.us"  height="16" width="16" border="0" /> Del.icio.us</a>');
document.write("</div>");

Or you can Download it here

To use it on your site or blog, just add the code:

<script src=”socialwidget.js” type=”text/javascript”></script>

The final effect is exactly what you see at the bottom of this blog post.

If you want to add more Social Networks, just find out their particular submission format and add them right in. I chose these four because they were recommended on a recent episode of Rush hour (doesn’t everyone listen to this?) which talked about which were the important social network sites for bookmarking.


If you liked this, then subscribe to my RSS feed

12 comments

  1. nikki Jul 8

    Probably the best tutorial so far….but just a suggestion
    Would it be possible to show the code and highlight in colour where we are supposed to enter our site URL and title etc.

    I did this as I believed it was supposed to be but it just ended up as a mess of text when I pasted into Dreamweaver

  2. jame Aug 12

    you can try this out
    http://www.mybuny.com/thecommunity/web-design-forum/1428-widget-submit-buttons.delicious#post1548

  3. corelcao Oct 30

    relelt

  4. stockpix Oct 31

    I’m also having trouble with getting this to work in a straight html page. Are these variables from wordpress or should it work on any old page. It does not look like the variables need to be declared in your page, but I clearly seem to be missing something here since nothing at all is showing up.

  5. bocmonvar Nov 20

    racvitaa

  6. Discount Coupons Jan 29

    Hi,

    I have tried adding a different code from addthis.com but that disturbs my design. I would like to add this code to but I guess but it does not have all the social bookmarks.

  1. Idea: One social bookmarking network to rule them all? | terrainnova.org
  2. Social Networking Articles Blog » Blog Archive » Tips for Increasing Your Traffic on Social Networking & Bookmarking Sites
  3. » You SHOULD Submit Manually to Social Bookmarking Sites or Should You Social Networking Articles Blog
  4. » List of Social Bookmarking Buttons & Widgets for Your Web Sites & Blogs Social Networking Articles Blog
  5. Social Bookmarking Widget
  6. Bookmarks for Pingomatic and Pingoat