我的“分享到 Pinterest”链接有问题。我有一个JSFiddle如果有帮助的话。
基本上 url
部分不会被带入我的新弹出窗口:'-(
这也是我的 Javascript:
$('.share.pinterest').click(function(e){
e.preventDefault();
var target = $(this),
url = target.data('url') || "";
var width = 575,
height = 400,
left = ($(window).width() - width) / 2,
top = ($(window).height() - height) / 2,
gplus = 'https://www.pinterest.com/pin/create/button/?url='+ url + '',
opts = 'status=1' +
',width=' + width +
',height=' + height +
',top=' + top +
',left=' + left;
window.open(gplus, 'Pinterest', opts);
});
非常感谢您对此问题的任何帮助和指导。
最佳答案
使用encodeURIComponent()
对您的url
参数进行编码
gplus = 'https://www.pinterest.com/pin/create/button/?url='
+ encodeURIComponent(url)
编辑:
这是因为 pinterest 将您的网址重定向到此:
https://www.pinterest.com/join/?next=/pin/create/button/
在 pinterest 完成的重定向过程中,它会为您编码 url,并将您输入的静态 url 更改为查询字符串版本。因此,您可能想像这样提交请求:
https://www.pinterest.com/join/?next=/pin/create/button/&url=
关于javascript - Pinterest 分享 HTML 链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26204882/