Pinterest共享HTML链接错误

Pinterest Share HTML Link error

本文关键字:错误 链接 HTML 共享 Pinterest      更新时间:2023-09-26

我的"分享到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正在将您的url重定向到以下位置:

https://www.pinterest.com/join/?next=/pin/create/button/

在pinterest完成的重定向过程中,它为您编码url,并将您输入的静态url更改为querystring版本。所以你可能想提交这样的请求:

https://www.pinterest.com/join/?next=/pin/create/button/&url=

<a href="http://www.pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>&media=<?php if(function_exists('the_post_thumbnail')) echo wp_get_attachment_url(get_post_thumbnail_id()); ?>&description=<?php echo get_the_title(); ?> - <?php echo get_permalink(); ?>" id="pinterest" target="_blank">Pinterest Pin It</a>