Javascript 抓取 URL 并插入 Facebook 页面选项卡应用程序的 Pinterest 按钮
我正在尝试在 Facebook 选项卡应用程序中的单个图像的产品页面上添加 Pinterest 按钮。
Pinterest 代码是从他们的好东西部分获取的,并且必须包含 URL、媒体 URL 和描述。
我对 Javascript 不太精通。我正在尝试提取 URL 并将其插入到单个项目的 Javascript 按钮中。请参阅下文;谢谢。
<a href="javascript:document.write(location.href);&media=http%3A%2F%2Fwww.mywebsite.net%2Ffiles%2Ftest%2Fks3.jpg&description=hello%20this%20is%20a%20product" class="pin-it-button" count-layout="horizontal">Pin It</a>
I am trying to add a Pinterest button onto a product page for a single image in a Facebook Tab app.
The Pinterest code is grabbed from their goodies section, and must include a URL, the Media URL and the Description.
I am not that proficient with Javascript. I am trying to pull the URL and insert into the Javascript button for a single item. Please see below; Thanks.
<a href="javascript:document.write(location.href);&media=http%3A%2F%2Fwww.mywebsite.net%2Ffiles%2Ftest%2Fks3.jpg&description=hello%20this%20is%20a%20product" class="pin-it-button" count-layout="horizontal">Pin It</a>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于您尝试让 Pinterest 按钮在 Facebook 页面选项卡中工作,因此由于无法知道您在 JavaScript 中所在的页面,因此这将不起作用。
此信息通过
signed_request
传递到服务器。您有几个选项可以执行此操作:请注意,这只是一个链接,除非您在页面上包含 Pinterest JavaScript (
//assets.pinterest.com/js/pinit.js
),否则它看起来不会像 Pin-It 按钮。如果您在客户端构建该链接,则必须在之后包含该 JavaScript,因此该链接将被带有实际 Pin-It 按钮的iframe
替换。Since you trying to get Pinterest button working in Facebook Page tab this will not work due to inability to know which Page you're on in JavaScript.
This info is passed to server with
signed_request
. You have couple of options to do so:Beware that this is just a link and it will not looks like Pin-It button until you including Pinterest JavaScript (
//assets.pinterest.com/js/pinit.js
) on a page. If you build that link in Client Side you must include that JavaScript after, so link will be replaced byiframe
with actual Pin-It button.