Search code examples
javascripthtmlfacebookfacebook-like

How to get Facebook Like button on JSFiddle?


So I want to put a Facebook like button on my website. I have used the code from the Facebook page but the button doesn't appear. Any help?

http://jsfiddle.net/genome314/204de8ry/

HTML

<div id="fb-root"></div>
<div class="fb-like" data-href="https://developers.facebook.com/docs/plugins/" data-layout="standard" data-action="like" data-show-faces="true" data-share="true"></div>

JavaScript

(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/sdk.js#xfbml=1&version=v2.0";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

This is where I got the code from https://developers.facebook.com/docs/plugins/like-button


Solution

  • I have no idea what could be wrong with the HTML5 like button, but the least I can say is that the iframe button works on jsfiddle:

    <iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&amp;width&amp;layout=standard&amp;action=like&amp;show_faces=true&amp;share=true&amp;height=80&amp;appId=YOUR_APP_ID" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:80px;" allowTransparency="true"></iframe>
    

    JSFiddle