Chris Pietschmann

husband, father, hacker, entrepreneur, futurist, innovator, autodidact


Adding a DotNetKicks Image/Badge via jQuery

A while ago Jon Galloway posted a short article titled "Adding a DotNetKicks image via JavaScript" which contains the small amount of JavaScript code necessary to add a Image / Badge to your web pages. The DotNetKicks Badge is essentially a link that allows users to go to to vote for you web page, and the badge also displays the total number of "kicks" that your page has received. Since jQuery has become insanely popular since Jon originally posted his JavaScript code, I thought I would post a jQuery version of his code.

Here's a simple demonstration of the Badge that the below jQuery/JavaScript code will generate:

kick it on

To use the below code you just need to follow the following steps:

  1. Create a <DIV> element wher you want the badge to be displayed.
  2. Set the <DIV>'s ID to 'postToolbar'.
  3. Make sure that the jQuery Library is included within the page.
  4. Include the below jQuery / JavaScript code within the page.


Here's the jQuery / JavaScript code:

$(function() {
    var currentPageUrl = document.location.protocol + "//" + + document.location.pathname;
                    attr('href', '' + currentPageUrl).
                    css({ border: 'none' }).
                        attr('src', '' + currentPageUrl).
                        css({ border: 'none' })

blog comments powered by Disqus