PDA

View Full Version : Changing "Digg This" anchor



deronsizemore
05-02-2007, 10:53 AM
I recently signed up for an account at Digg and was looking through their "Digg Tools" for websites and it seems that the only way to add a "Digg This" icon/link is to use their code which is javascript and it adds the default "digg this" with the number of diggs button.

I've seen all kinds of variations of this on websites, but I can't see on the digg site what anchor to use if I want to use one of the other icons/images they give you. Instead of "<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>" I would assume something along the lines of <a href="URL_here" /></a> and then I can style the anchor accordingly in the CSS to apply a different image.

KLB
05-02-2007, 01:20 PM
The boiled down code I use for my "Digg this" is:


<script type="text/javascript">
var desc;
if(!document.getElementsByName('DESCRIPTION')){des c='';}
else{desc=document.getElementsByName('DESCRIPTION' )[0].content;}
var t=document.title;
t=encodeURIComponent(t);
</script>
<a href="http://digg.com/submit" onclick="window.open('http://digg.com/submit?phase=2&url='+encodeURIComponent(location.href)+'&title='+t+'&bodytext='+desc, 'Social','height=440,width=700, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, directories=no, status=yes'); return false;"><img src="http://{Your domain name}/images/digg_16x16.gif" alt="">Digg</a>

The beauty of the code is that it doesn't have to be modified from page to page, Javascript figures out the URL, title and description for you. The one catch is that the word "description" in "document.getElementsByName('DESCRIPTION')" needs to match the case you use for your meta description tag.