2012-08-16 41 views
4

分享我分享Pinterest上這樣的JavaScript函數:如何Pinterest上

function shareOnPinterest(url, desc, coverImage){ 

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

window.open(str, "_blank");   

} 

的URL似乎是工作的罰款,但是當我點擊Pin它按鈕,它沒有腳的板。

我在我的頁面上也有對這個Pinterest JavaScript的參考。

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

有什麼我做錯了嗎?還是有沒有其他方式可以在Pinterest上分享?

謝謝。

+0

你'shareOnPinterest'功能不需要'pinit.js'。你在哪裏找到這個腳本? – Raptor 2012-08-16 06:17:18

+0

我在這裏找到了http://pinterest.com/about/goodies/網址,它說需要在頁面上包含pinit.js並且我自己做了腳本。 – zaw 2012-08-16 06:23:31

+0

你誤會了。您應該查看「Pin It」按鈕中的代碼。 – Raptor 2012-08-16 07:36:30

回答

2

我不確定你想要什麼......一個用於你的網頁的按鈕或簡單地固定圖像?

此代碼工作引腳圖片:

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

謝謝m8我發現問題是因爲共享文本。我從共享文本中刪除「&」,現在它的工作:)歡呼聲 – zaw 2012-08-16 09:13:48