Update FB:Like URL Dynamically using JavaScript

Posted by br4inwash3r on Stack Overflow See other posts from Stack Overflow or by br4inwash3r
Published on 2010-05-04T09:24:16Z Indexed on 2010/05/04 9:28 UTC
Read the original article Hit count: 150

Filed under:
|
|

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

right now i've been able to change the href attribute of the fb:like tag (i've pasted the code below). but that doesn't work. perhaps i have to re-initiate the FB:Like button, but so far i can't figure out how..

function update_share(container, url) {
  // update fb:like href value
  var container = container[0] || document.body;
  var button = container.getElementsByTagName('fb:like');
  button[0].setAttribute('href', url);
}

any help would be appreciated. thx..

© Stack Overflow or respective owner

Related posts about facebook

Related posts about JavaScript