简体   繁体   中英

Facebook like button is not showing

I am trying to add facebook like button on a web-page. I took the exact code from https://developers.facebook.com/docs/reference/plugins/like/ ,but still the like button is not displaying at all. I tried all the three versions HTML5, XFBML and IFRAME but none of them worked. I tried to run the code in chrome firefox and even internet explorer but it dint work in any. I dont have any facebook disconnect extension etc installed in my browser. Please tell me what wrong am i doing...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:fb="http://ogp.me/ns/fb#">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 </head>
 <body>
  <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_US/all.js#xfbml=1&appId=***appId***";
  fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));</script>
  <div class="fb-like" data-href="http://live2.cricbuzz.com/live/scorecard/11200/Mumbai-v-Delhi" data-send="false" data-layout="button_count" data-width="50" data-show-faces="false" data-colorscheme="dark" data-font="verdana"></div>
 </body>
 </html>

Iv put my appId at the appropriate place...

This exact code works perfectly here... http://jsfiddle.net/dmcs/HS5Lp/1/ ... but not when i run it on my browser.. it gives an error... ->Failure to load resource :file://connect.facebook.net/en_US/all.js#xfbml=1&appId=113830492072210

I have no clue why this is happening... Please help if you know about it..

Vikram,

I see what your problem is. Though u wont find much of a difference between your script call and the one written below. But this will hopefully make a difference for you and solve your error.

<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 = "http://connect.facebook.net/en_US/all.js#xfbml=1&appId=***appId***";
  fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));
</script>

Just put in your App_Id in the above script.

Cheers, Rahul

You can see here it works perfectly.

http://jsfiddle.net/dmcs/HS5Lp/1/

Maybe your page where the like button is going is not as clean as you think. Check out your browser's javascript console to see if there's any error messages Add some logging into your javascript to ensure it is running.

I also checked this site: http://live2.cricbuzz.com/live/scorecard/11200/Mumbai-v-Delhi and the like button is working fine there.

Do you have a link to the code that is not working?

There are a few things you can fix on your page. See results from the linter tool here: http://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Flive2.cricbuzz.com%2Flive%2Fscorecard%2F11200%2FMumbai-v-Delhi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM