Pergunta

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>
Foi útil?

Solução

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:

  • Build the link to page that will be linked to "Pin" server-side
  • Pass information about Page and Page Tab to client side and build the link here.

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 by iframe with actual Pin-It button.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top