Saturday, July 14, 2012

how to create a custom Pinterest “Pin It” button for your website

Here is the Javascript code I use to create a Pin It button for a web page using a custom graphic:

<div>
<a href="javascript:void((function(){var%20e=document.createElement('script'); e.setAttribute('type','text/javascript'); e.setAttribute('charset','UTF-8'); e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999);document.body.appendChild(e)})());"> <img src="images/pinit.jpg" alt="Pin It" /></a> </div>  
You will want to change the path to the image in the code above so that it points to the graphic that you want to use for the Pin It button. You could also substitute text for the graphic if you prefer.

No comments:

Post a Comment