javascript - Facebook like button is not showing - Stack Overflow

I am trying to add facebook like button on a web-page. I took the exact code from,but still the like

I am trying to add facebook like button on a web-page. I took the exact code from / ,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" ".dtd">
<html xmlns: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/en_US/all.js#xfbml=1&appId=***appId***";
  fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));</script>
  <div class="fb-like" data-href="" 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... / ... but not when i run it on my browser.. it gives an error... ->Failure to load resource :file://connect.facebook/en_US/all.js#xfbml=1&appId=113830492072210

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

I am trying to add facebook like button on a web-page. I took the exact code from https://developers.facebook./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/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/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./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/dmcs/HS5Lp/1/ ... but not when i run it on my browser.. it gives an error... ->Failure to load resource :file://connect.facebook/en_US/all.js#xfbml=1&appId=113830492072210

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

Share Improve this question edited Apr 16, 2012 at 19:29 Vikram asked Apr 16, 2012 at 18:22 VikramVikram 5091 gold badge11 silver badges28 bronze badges 2
  • Checking the basics..are there are javascript errors on the page? – sethcall Commented Apr 16, 2012 at 18:26
  • My javascript gave an error:- Failed to load resource:file://connect.facebook/en_US/all.js#xfbml=1&appId="theappid" .. i dont know why it is giving this error coz my appId is correct – Vikram Commented Apr 16, 2012 at 18:59
Add a ment  | 

2 Answers 2

Reset to default 2

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/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/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./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./tools/debug/og/object?q=http%3A%2F%2Flive2.cricbuzz.%2Flive%2Fscorecard%2F11200%2FMumbai-v-Delhi

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745389530a4625597.html

相关推荐

  • javascript - Facebook like button is not showing - Stack Overflow

    I am trying to add facebook like button on a web-page. I took the exact code from,but still the like

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信