Adding a DotNetKicks image via Javascript - Jon Galloway

Adding a DotNetKicks image via Javascript

Update: This post is pretty old. While it still works, I'd recommend doing this with jQuery now. Chris Pietschmann wrote a followup with a jQuery implementation, so go check that out.

About DotNetKicks

DotNetKicks is a nice social bookmarking system (like Digg, Reddit, etc.) that's specific to .NET development issues. Users submit cool links, other users vote on it, popular links show up the front page and in an RSS feed. It lets you know what's going on in the .NET world right away without having to spend every second of the day scanning thousands of blogs.

Kick It!

One of the cool features is an image which shows the number of "kicks" a page has received. The image links back to the vote page, so you can just click the "kick it" button to vote. Neat. Here's a button from a recent post I did about connection string protocols:

Adding a Kick It button via Javascript

Some blog engines support the "kick it" button. The system I'm using - weblogs.asp.net - has a "kick it" link on every post, but doesn't show the images. It's a hosted system, so the only real way to tweak things is via CSS and Javascript. I hacked together some Javascript to add the kick count button. This is pretty generic, with the exception of the 'postToolbar' ID. You'll want to replace that with DIV (or some other container element) on your page.

Since the Kick counts are based on specific posts, this only displays the image when you're viewing an individual post.

UPDATE: Changed from Submit to Kick url, and changed the submitted url so it doesn't include the querystring.

addLoadEvent(AddDotNetKicks); function addLoadEvent(fn) { if (window.addEventListener) window.addEventListener('load', fn, false) else if (window.attachEvent) window.attachEvent('onload', fn); } function AddDotNetKicks() { var insertLocation = document.getElementById('postToolbar'); if(insertLocation) { var currentPageUrl = document.location.protocol + "//" + document.location.host + document.location.pathname; var dotnetkicksLink = document.createElement('a'); dotnetkicksLink.href = 'http://www.dotnetkicks.com/kick/?url=' + currentPageUrl; var dotnetkicksImg = document.createElement('IMG'); dotnetkicksImg.src = 'http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=' + currentPageUrl; dotnetkicksImg.border = 0; dotnetkicksLink.appendChild(dotnetkicksImg); insertLocation.appendChild(dotnetkicksLink); } }

To do and notice

The DotNetKicks services are based on a page URL, so the Javascript pulls that in using document.location properties.

The script works by appending HTML elements to an existing DIV with an ID of 'postToolbar'. That element won't exist when the page is being loaded, so we need to wait on running the Javascript until loading is complete. I'm using the addLoadEvent to attach a load handler. I wrote more about that in a previous post about adding a logo to SQL Server Reporting Services reports.

Published Thursday, March 08, 2007 2:35 PM by Jon Galloway

Comments

# re: Adding a DotNetKicks image via Javascript

Very nice, thanks for creating this Jon.

Friday, March 09, 2007 10:48 AM by Gavin Joyce

# re: Adding a DotNetKicks image via Javascript

Many thanks was very usefull.

Friday, March 09, 2007 1:19 PM by Adel

# re: Adding a DotNetKicks image via Javascript

You're a star and I get to kick you!

Wednesday, March 14, 2007 5:23 AM by Haacked

# re: Adding a DotNetKicks image via Javascript

Du musst ein Fachmann sein - wirklich guter Aufstellungsort, den du hast!

Wednesday, March 14, 2007 9:33 PM by ...

# re: Adding a DotNetKicks image via Javascript

Very useful stuff!

Wednesday, August 01, 2007 6:12 AM by dotnetUncle - .NET Interview Questions

# New DNK Features: Kick Spy

New DNK Features: Kick Spy

Monday, September 17, 2007 7:58 AM by Gavin Joyce's Blog

# New DNK Features: Kick Spy & Shoutbox

This week there have been over 100 commits to the DotNetKicks open source trunk. Some fantastic new features

Monday, September 17, 2007 8:01 AM by Gavin Joyce's Blog

# re: Adding a DotNetKicks image via Javascript

è difficilissimo trovare il costruttore di Image / window.document.images[] per ie è undefined x netscape e mozilla è [HTMLImageElement]

purtroppo mi devo sorbì argomenti che non c'entrano nulla!!!!!!!!!!!!!!!

Friday, December 07, 2007 5:36 AM by fabrizio

# DotNetKicks PlugIn for Windows Live Writer

I've been using some javascript snippet that generates a DotNetKicks KickIt image for a blog post. I found the javascript to insert the KickIt link in a post by Jon Galloway . (Thanks Jon!) I tweaked his javascript to suit my needs and it works well.

Wednesday, April 30, 2008 2:26 AM by JohnPapa.net

# DotNetKicks PlugIn for Windows Live Writer

I've been using some javascript snippet that generates a DotNetKicks KickIt image for a blog post

Wednesday, April 30, 2008 2:35 AM by John Papa [MVP C#]

# Chalk Extension for .NET Kick It Button

Since I'm on a Graffiti CMS kick this week, I figured I'd share a little Chalk extension I wrote to add a "Kick It" button ( www.dotnetkicks.com ) to a Graffiti view. I found some code on Jon Galloway's blog on doing this via Javascript and modified it

Monday, August 11, 2008 6:35 PM by Crazeegeekchick.com

# Chalk Extension for .NET Kick It Button

Since I'm on a Graffiti CMS kick this week, I figured I'd share a little Chalk extension I wrote to add a "Kick It" button ( www.dotnetkicks.com ) to a Graffiti view. I found some code on Jon Galloway's blog on doing this via Javascript and

Monday, August 11, 2008 7:10 PM by Crazeegeekchick.com

# re: Adding a DotNetKicks image via Javascript

eFront-Интернет магазин Бытовой и компьютерной техники www.e-front.com.ua

Monday, January 12, 2009 5:31 AM by busrider

# re: Adding a DotNetKicks image via Javascript

Gute Arbeit hier! Gute Inhalte.

Friday, March 06, 2009 10:08 PM by ...

# re: Adding a DotNetKicks image via Javascript

Dies ist ein gro�er Ort. Ich m�chte hier noch einmal.

Sunday, March 08, 2009 5:27 PM by ...

# Adding a DotNetKicks Image/Badge via jQuery

Adding a DotNetKicks Image/Badge via jQuery

Monday, July 20, 2009 7:23 PM by Chris Pietschmann

# re: Adding a DotNetKicks image via Javascript

Now that Greenpeace has come clean on their statement, maybe Dr. ,

Thursday, October 22, 2009 12:14 PM by BadGirl99

# dotnet-kicks.de Button mit JavaScript einbinden

dotnet-kicks.de Button mit JavaScript einbinden

Sunday, November 15, 2009 3:40 PM by dotnet-kicks.de Blog

# DotNetKicks: Digg for .NET Developers | TechBubble

Pingback from  DotNetKicks: Digg for .NET Developers | TechBubble

Thursday, December 24, 2009 10:44 PM by DotNetKicks: Digg for .NET Developers | TechBubble

# re: Adding a DotNetKicks image via Javascript

Thanks. That's useful. Gonna use it on my blog.

Sunday, September 19, 2010 8:00 AM by Jaroslaw Dobrzanski

# re: Adding a DotNetKicks image via Javascript

When all else is lost the future still remains.

-----------------------------------

Saturday, December 18, 2010 9:56 AM by html5 ipad app

# re: Adding a DotNetKicks image via Javascript

I'm pleased that you said that post??

<a href="www.iconiccigars.com/.../Davidoff-Colorado-Claro-Short-Perfecto-Bx-10.html">Davidoff Colorado Claro Short Perfecto</a>

Thursday, December 23, 2010 2:37 AM by Rudolph

# re: Adding a DotNetKicks image via Javascript

, and pigs fly??

<a href="www.cigars-now.com/.../a>

Thursday, December 23, 2010 8:25 PM by Felix

# re: Adding a DotNetKicks image via Javascript

, ROFL??

<a href="www.live-girls-webcam-chat.com/">aachen chat</a>

Friday, December 24, 2010 7:27 PM by June

# re: Adding a DotNetKicks image via Javascript

Maybe the BEST thing that I read in my life :P

Sincerely,

<a href="www.cigars-now.com/.../a>

Saturday, December 25, 2010 2:59 AM by Gino

# re: Adding a DotNetKicks image via Javascript

FAIL.

<a href="www.cigars-now.com/.../a>

Saturday, December 25, 2010 8:46 PM by Patricia

# re: Adding a DotNetKicks image via Javascript

Great writing, been waiting for that =D

<a href="www.live-girls-webcam-chat.com/">lablue chat</a>

Sunday, December 26, 2010 4:25 PM by Noe Edwards

# re: Adding a DotNetKicks image via Javascript

Hey , whatever dude :P

<a href="www.cigars-now.com/.../a>

Monday, December 27, 2010 6:54 PM by Henry Roy

# re: Adding a DotNetKicks image via Javascript

Great read! I wish you could follow up on this topic :P

Warmest Regards,

<a href="www.cigars-now.com/.../a>

Tuesday, December 28, 2010 7:01 PM by Mae Meyers

# re: Adding a DotNetKicks image via Javascript

is the best?!

<a href="http://alternativemedicine.org.in">alternative medicine courses in india</a>

Wednesday, December 29, 2010 4:30 PM by Zachery

# re: Adding a DotNetKicks image via Javascript

I am glad you said that???

<a href="www.live-couples-webcam-chat.com/webcam-chat-couples.html">webcam überwachung</a>

Thursday, December 30, 2010 6:03 AM by Cliff

# re: Adding a DotNetKicks image via Javascript

Great post! I want to see a follow up on this topic =D

<a href="www.cigars-now.com/.../a>

Thursday, December 30, 2010 5:33 PM by Grace Kidd

# re: Adding a DotNetKicks image via Javascript

Vivian, cool story bro :D

<a href="www.live-video-webcam-chat.com/webcam-chat-video.html">n& chat</a>

Friday, December 31, 2010 5:59 PM by Donn

# re: Adding a DotNetKicks image via Javascript

Teddy is the best :P

-Yours Truly

Rosario

<a href="www.live-fetisch-webcam-chat.com/.../a>

Saturday, January 01, 2011 4:03 PM by Christina

# re: Adding a DotNetKicks image via Javascript

Claudia is the best..

<a href="www.live-girls-webcam-chat.com/webmaster.html">geld verdienen mit</a>

Sunday, January 02, 2011 5:20 PM by Lou

# re: Adding a DotNetKicks image via Javascript

Lorena ftw :P

<a href="http://alternativemedicine.org.in">alternative medicine courses in india</a>

Monday, January 03, 2011 8:36 AM by Milagros Lucero

# re: Adding a DotNetKicks image via Javascript

I'm happy you took the time and said this?!?

<a href="www.erotiklobby.com/.../a>

Tuesday, January 04, 2011 5:56 PM by Rena Wagner

# re: Adding a DotNetKicks image via Javascript

Dino rocks??

<a href="www.iconiccigars.com/.../Davidoff-Colorado-Claro-Special-T-Bx-10.html">Davidoff Colorado Claro Special T</a>

Wednesday, January 05, 2011 7:27 PM by Morgan Blankenship

# re: Adding a DotNetKicks image via Javascript

Carrie rocks :P

<a href="alternativemedicine.org.in/aromatherapy.html">aromatherapy institute</a>

Thursday, January 06, 2011 8:10 PM by Lori

# re: Adding a DotNetKicks image via Javascript

Marcia is the greatest.

Lakeisha

<a href="www.finansa-credit.com/">finansa credit</a>

Saturday, January 08, 2011 10:08 AM by Darlene Marshall

# re: Adding a DotNetKicks image via Javascript

Kip, ROFL.

<a href="www.asparagus-soap.com/.../scrubs.html">Oatmeal scrubs</a>

Saturday, January 08, 2011 7:17 PM by Tamika Horner

# re: Adding a DotNetKicks image via Javascript

-----------------------------------------------------------

"Please, are you able to PM me and inform me couple of additional thinks about this, I'm actually lover of the website.

Sunday, January 09, 2011 12:56 PM by cool ipad case

# re: Adding a DotNetKicks image via Javascript

Could be the top page that I read all year!

<a href="www.asparagus-soap.com/.../scrubs.html">Oatmeal scrub</a>

Sunday, January 09, 2011 1:59 PM by Sadie Vogel

# re: Adding a DotNetKicks image via Javascript

Hey Rory, wtf!!!

Kristi

<a href="www.ipcounter.net/">counter kostenlos</a>

Monday, January 10, 2011 6:04 PM by Ramon

# re: Adding a DotNetKicks image via Javascript

Constance, really?!?

<a href="www.ipcounter.net/">counter ohne werbung</a>

Tuesday, January 11, 2011 8:11 AM by Levi

# re: Adding a DotNetKicks image via Javascript

Great read! I want to see a follow up to this topic?

Kindest Regards,

Tommie

<a href="alternativemedicine.org.in/acupressure.html">acupressure school in india</a>

Tuesday, January 11, 2011 7:55 PM by Crystal

# re: Adding a DotNetKicks image via Javascript

Tamra FAIL???

Jorge

<a href="http://www.asparagus-soap.com">Natural Soap</a>

Wednesday, January 12, 2011 10:20 PM by Carrie

# re: Adding a DotNetKicks image via Javascript

Great writing! I want to see a follow up on this topic :)

-Best Regards

Otis

<a href="www.netezines.net/bowtrol-colon-control-review">bowtrol colon control review</a>

Thursday, January 13, 2011 8:15 PM by Dianne Perez

# re: Adding a DotNetKicks image via Javascript

I wonder exactly what Earl will change about that?!?

Will

<a href="www.asparagus-soap.com/.../scrubs.html">Oatmeal scrubs</a>

Friday, January 14, 2011 8:14 PM by Gabriela

# re: Adding a DotNetKicks image via Javascript

Great post, I have been waiting for that..

-Warmest regards

Jana

<a href="www.wild-ginseng.org/">sibirischer ginseng</a>

Saturday, January 15, 2011 8:15 PM by Pasquale

# re: Adding a DotNetKicks image via Javascript

Timothy ftw!?!

Meghan

<a href="alternativemedicinecourse.com/.../bach-flower-remedy-courses">bach flower course</a>

Monday, January 17, 2011 8:59 PM by Fredrick Locke

# re: Adding a DotNetKicks image via Javascript

Great blog post, I've been after that :)

Rex

<a href="eva.utpl.edu.ec/.../">hydroxatone cream</a>

Tuesday, January 18, 2011 1:18 PM by Brianna Hyde

# re: Adding a DotNetKicks image via Javascript

I am curious just what Vance thinks about that!?!

Olen

<a href="www.fitness-buch.com/">fitness bamberg</a>

Tuesday, January 18, 2011 10:00 PM by Jamie

# re: Adding a DotNetKicks image via Javascript

Great writing! You may want to follow up to this topic...

<a href="alternativemedicinecourse.com/.../acupressure-courses">acupressure course</a>

Wednesday, January 19, 2011 7:43 PM by Jan

# re: Adding a DotNetKicks image via Javascript

Great read! I want to see a follow up on this topic?!?

<a href="http://webreputationmanagement.info">My Site</a>

Thursday, January 20, 2011 1:30 AM by Trevor

# re: Adding a DotNetKicks image via Javascript

This is the most influential read I have read all year!?

Geraldine

<a href="alternativemedicinecourse.com/.../hypnotherapy-courses">hypnotherapy courses</a>

Thursday, January 20, 2011 11:16 PM by Willie

# re: Adding a DotNetKicks image via Javascript

I want to know  what Dawn thinks with that :)

Elnora

<a href="data-recovery-information.com/hard-drive-data-recovery.html">Hard drive data recovery</a>

Friday, January 21, 2011 9:00 PM by Liliana

# re: Adding a DotNetKicks image via Javascript

I am glad you said that.

Vanessa

<a href="http://www.cigars-now.com">Tobacco Shop</a>

Saturday, January 22, 2011 3:40 AM by Tamara

# re: Adding a DotNetKicks image via Javascript

Stefan FAIL...

Best Regards,

Billie

<a href="www.houseofrapidcreditrepair.com/">credit repair</a>

Saturday, January 22, 2011 11:25 PM by Kathie Kurtz

# re: Adding a DotNetKicks image via Javascript

Great writing! I wish you could follow up to this topic!

-Kindest regards,

Dudley

<a href="http://www.gume-oblak.si">gume</a>

Monday, January 24, 2011 1:34 AM by Cora

# re: Adding a DotNetKicks image via Javascript

This is the BEST blog that I read this month!!

Stephen

<a href="www.nacht-creme.net/">dermatop creme"</a>

Tuesday, January 25, 2011 9:41 PM by Kelly Pelletier

# re: Adding a DotNetKicks image via Javascript

This is the best thing that I have read today?

<a href="www.nacht-creme.net/">creme aloe vera"</a>

Wednesday, January 26, 2011 7:24 PM by Art Macdonald

# re: Adding a DotNetKicks image via Javascript

I want to know just what Caitlin will say with this.

<a href="www.cigars-now.com/.../padron.html">padron cigar</a>

Thursday, January 27, 2011 9:39 PM by Mandy Goode

# re: Adding a DotNetKicks image via Javascript

The BEST post I have read today!!

<a href="neil49walter.livejournal.com/704.html">Belanja Baju Online</a>

Saturday, January 29, 2011 1:02 AM by Josiah

# re: Adding a DotNetKicks image via Javascript

I am glad you said that :P

<a href="http://www.gume-oblak.si">gume</a>

Saturday, January 29, 2011 9:28 PM by Jared Shultz

# re: Adding a DotNetKicks image via Javascript

I am wondering exactly what Ernestine says with this???

Marla

<a href="http://www.gume-oblak.si">gume</a>

Sunday, January 30, 2011 9:07 PM by Jonas

# re: Adding a DotNetKicks image via Javascript

I am curious  what Neil will say with this!?!

Sincere regards

Beverly

<a href="www.cigars-now.com/.../a>

Monday, January 31, 2011 6:52 PM by Valentin Peterson

# re: Adding a DotNetKicks image via Javascript

Great writing, I have been waiting for that?

<a href="www.oregonlngpropertysearch.com/">moncler jacket</a>

Tuesday, February 01, 2011 12:32 AM by Branden

# re: Adding a DotNetKicks image via Javascript

Cora rocks!!

<a href="http://www.gume-oblak.si">gume</a>

Wednesday, February 02, 2011 2:17 AM by Sue

# re: Adding a DotNetKicks image via Javascript

Great post! Maybe you could do a follow up to this topic!

<a href="www.camchatladies.com/">chat ab 50</a>

Friday, February 04, 2011 9:11 PM by Rachael Godwin

# re: Adding a DotNetKicks image via Javascript

I wonder exactly what Dannie can do with this...

<a href="www.sumobulldogs.com/">english bulldog for sale</a>

Saturday, February 05, 2011 6:54 PM by Catalina

# re: Adding a DotNetKicks image via Javascript

Jesus fail!!!

<a href="www.camchatladies.com/">freunde chat</a>

Sunday, February 06, 2011 9:40 AM by Jenifer Pinto

# re: Adding a DotNetKicks image via Javascript

Great post! You might want to follow up to this topic...

<a href="http://url.com">keyword one</a>

Monday, February 07, 2011 7:25 AM by Laverne Lanier

# re: Adding a DotNetKicks image via Javascript

Tuesday, February 08, 2011 7:04 PM by Ronda

# re: Adding a DotNetKicks image via Javascript

The GREATEST thing that I read all day!!!

<a href="www.was-frauen-wollen.com/">sperma zu langsam</a>

Wednesday, February 09, 2011 4:47 PM by Carol Sylvester

# re: Adding a DotNetKicks image via Javascript

I need to hear just what Jo will do about that :)

<a href="www.asparagus-soap.com/.../scrubs.html">Oatmeal scrub</a>

Wednesday, February 09, 2011 10:31 PM by Liza Armstrong

# re: Adding a DotNetKicks image via Javascript

I need to hear exactly what Mario says with that?!?

-Thank You,

Antonio

<a href="data-recovery-information.com/">Data recovery information</a>

Thursday, February 10, 2011 9:14 PM by Ora

# re: Adding a DotNetKicks image via Javascript

I am glad you said that!!

<a href="http://www.mechoddl.com">Kiddie</a>

Saturday, February 12, 2011 5:22 AM by Lynda

# re: Adding a DotNetKicks image via Javascript

Could be the most amazing blog that I have read in my life??

-Fondest regards

Kristine

<a href="www.kredite-einfach.com/">finanzierung ohne schufa</a>

Saturday, February 12, 2011 8:24 PM by Pasquale Wolf

# re: Adding a DotNetKicks image via Javascript

Great post! You should definitely follow up to this topic :P

Louise

<a href="www.kredite-einfach.com/">sofortkredit ohne schufa</a>

Sunday, February 13, 2011 6:07 PM by Cherie

# re: Adding a DotNetKicks image via Javascript

I am curious  what Issac has to say about this?

Eddie

<a href="www.oregonlngpropertysearch.com/">moncler jacket</a>

Sunday, February 13, 2011 11:12 PM by Lilian Chavez

# re: Adding a DotNetKicks image via Javascript

Great blog post, I have been waiting for that?

Dana

<a href="http://www.yutube.si">yutube</a>

Monday, February 14, 2011 8:55 PM by Earnestine

# re: Adding a DotNetKicks image via Javascript

Adeline, whatever dude?!

<a href="www.kuhinje-nokturno.si/">vgradne omare</a>

Tuesday, February 15, 2011 3:31 AM by Alberto George

# re: Adding a DotNetKicks image via Javascript

Great post! Maybe you could do a follow up to this topic..

<a href="www.was-frauen-wollen.com/">sperma im alter</a>

Wednesday, February 16, 2011 9:17 PM by Suzanne Cardona

# re: Adding a DotNetKicks image via Javascript

Fernando, yea right!

Burl

<a href="http://www.gume-oblak.si">gume</a>

Friday, February 18, 2011 1:30 AM by Marion

# re: Adding a DotNetKicks image via Javascript

Great writing! You might want to follow up on this topic!?!

<a href="www.butikonlinemurah.com/">Butik Online Murah</a>

Saturday, February 19, 2011 12:03 AM by Lesley Simmons

# re: Adding a DotNetKicks image via Javascript

I am glad you said that :)

<a href="http://www.SecurityCubed.com">security systems for home</a>

Saturday, February 19, 2011 10:15 PM by Leslie

# re: Adding a DotNetKicks image via Javascript

"Congratulations on possessing one in every of probably the most sophisticated blogs Ive arrive throughout in some time!  Its just extraordinary how significantly it is possible to consider away from  a thing simply because of how visually stunning it truly is.  Youve place with each other a fantastic website area --great graphics, videos, layout.  This is certainly a must-see  weblog!"

--------------------------------------------------------------------    

Inner Asian and Altaic Studies

Saturday, March 12, 2011 8:52 PM by toaster oven reviews

# re: Adding a DotNetKicks image via Javascript

I was recommended this website by my cousin. I'm not sure whether this post is written by him as nobody else know such detailed about my trouble. You are amazing! Thanks!

<b><a href="brevardgreens.com/all-about-home-security

">cheap Home Security Monitoring

<a/><b/>

Sunday, April 10, 2011 10:27 PM by Home Security Monitoring

# re: Adding a DotNetKicks image via Javascript

Rather cool place you've got here. Thanks for it. I like such topics and everything connected to them. I definitely want to read more soon.  

Avril Kuree    

<a href="www.pickescort.com/">www escort service</a>

Saturday, April 16, 2011 7:04 PM by Avril Kuree

# re: Adding a DotNetKicks image via Javascript

wkwfq retractable awnings bgagjl

Monday, April 18, 2011 7:07 AM by awning crank

# re: Adding a DotNetKicks image via Javascript

"Dental packages in Costa Rica include all expenses like X-ray, prosthesis, and so forth., on the clinic, as well as the dentist's fees, and nevertheless they're 50-70% less expensive than anything you  will locate inside the US, UK, Canada."

--------------------------------------------------------------------        

History and Literature

Wednesday, April 27, 2011 9:27 AM by newest iphone apps

# re: Adding a DotNetKicks image via Javascript

Rather cool place you've got here. Thanx for it. I like such themes and anything that is connected to them. I would like to read a bit more soon.  

Anete Simpson    

<a href="www.pickescort.com/">female escorts in London</a>

Thursday, April 28, 2011 10:50 PM by Anete Simpson

Leave a Comment

(required) 
(required) 
(optional)
(required)