Update FB:Like URL Dynamically using JavaScript

前端 未结 5 792
感动是毒
感动是毒 2020-12-04 18:25

i\'d like to change the URL to like of an FB:Like button dynamically using javascript.

right now i\'ve only been able to change the href attribute o

5条回答
  •  感动是毒
    2020-12-04 18:56

    I think you have a few options...

    1. Remove the element, build and append a string of XFBML and then parse the parent object an XFBML.parse call.

    2. Remove the element or it's container, build and append an actual XFBML object using

    3. Build an iframe container gets passed in the like url (with a GET) from the parent page. You can do this without even using a real backend if you can get the query string in JS. Then just build the markup before you init the facebook SDK and the like button will render. Facebook iframes all their stuff anyway, so this method isn't as clunky as it sounds. Tried this, works well.

提交回复
热议问题