0

The default facebook button to like your facebook page is going to look pretty rubbish on my website so I wanted to create a custom designed button.

I have the code below trying to use jquery trigger to mimic the clicking of the facebook like button. I don't think this works though as the facebook like button is within an iFrame.

Can anyone see how this could work?

$(document).ready( function() {
    $("a").live("click", function() {
        $(".connect_widget_like_button").trigger('click');
        return false;
    });
});

And

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=164366676978480";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like-box" data-href="http://www.facebook.com/Google" data-width="292" data-show-faces="false" data-stream="false" data-header="false"></div>

<a href="#">test button</a>
Tom
  • 12,776
  • 48
  • 145
  • 240

1 Answers1

0

You think right! That won't work because of the iframe. Also check out the following question for more details about changing the like button an legal matters. Facebook, how to change like button image?

Community
  • 1
  • 1
T. Junghans
  • 11,385
  • 7
  • 52
  • 75