我目前正在尝试将社交网络的按钮添加到我的网站,但我遇到了 Pintesrest 的 Pin It 按钮的问题。我想动态更改 pin 的 URL,但不幸的是,它似乎不起作用。我做错什么了吗?
<script type="text/javascript">
var urlpin = document.location.href;
function buildPinUrl(urlpin, urlmedia, description) {
return '//pinterest.com/pin/create/button/?'+
'url='+encodeURIComponent(urlpin)+
'&media='+encodeURIComponent(urlmedia)+
'&description='+encodeURIComponent(description);
}
$(document).ready(function(){
var urlmedia = $("#stamp1").attr("src");
var description = $("#title").text();
var goodurl = buildPinUrl(urlpin, urlmedia, description);
$('#pinbtn').attr('href', goodurl);
});
</script>
这里是按钮:
<!-- Pin It Button --><a id="pinbtn" href="//pinterest.com/pin/create/button/?url=http%3A%2F%2Fcollectionnies.com&media=http%3A%2F%2Fcollectionnies.com&description=Next%20stop%3A%20Collectionnies" data-pin-do="buttonPin" data-pin-config="beside"><img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" /></a><!-- Pin It Button -->
谢谢你的帮助。