zaw
zaw

Reputation: 684

How to share on Pinterest

I have a JavaScript function for sharing on Pinterest like this:

function shareOnPinterest(url, desc, coverImage){

var str = "http://pinterest.com/pin/create/button/?url=" + encodeURIComponent(url) + "&media=" + coverImage + "&description=" +
desc;

window.open(str, "_blank");         

}

The URL seems to be working fine but when I click Pin It button it doesn't pin to the board.

I have a reference to this Pinterest JavaScript on my page too.

<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>

Is there anything I did wrong or is there any other way to share on Pinterest?

Thanks.

Upvotes: 5

Views: 6945

Answers (1)

mng
mng

Reputation: 50

I'm not sure what you're wanting... a button for your webpage or to simply pin images?

This codes works to pin images:

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)})());

Upvotes: 2

Related Questions