如何在 Pinterest 上分享

zaw*_*zaw 5 javascript 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");         

}
Run Code Online (Sandbox Code Playgroud)

该 URL 似乎工作正常,但当我单击“固定它”按钮时,它没有固定到板上。

我的页面上也有对此 Pinterest JavaScript 的引用。

<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>
Run Code Online (Sandbox Code Playgroud)

我是否做错了什么或者有其他方式可以在 Pinterest 上分享吗?

谢谢。

小智 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)})());
Run Code Online (Sandbox Code Playgroud)