Facebook的按钮不显示

问题描述:

我想添加一个Facebook的按钮到一个网站,但它从来没有出现。Facebook的按钮不显示

下面是从我的网页上的相关细节:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:fb="http://www.facebook.com/2008/fbml" 
    xmlns:og="http://opengraphprotocol.org/schema/" dir="ltr" lang="en" xml:lang="en"> 

<head id="Head1" runat="server"> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
    <meta property="og:title" content="[____].com" /> 
    <meta property="og:type" content="blog" /> 
    <meta property="og:url" content="http://www.[____].com/" /> 
    <meta property="og:image" content="http://[____].gif" /> 
    <meta property="og:site_name" content="[____].com" /> 
    <meta property="fb:app_id" content="[____]" /> 
    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=News+Cycle" /> 
    <link rel="Stylesheet" type="text/css" href="../../Content/css/[____].min.css" media="screen, projection" /> 
</head> 

<body> 

    <div id="fb-root"></div> 
    <script> 
     window.fbAsyncInit = function() { 
      FB.init({ 
        appId: '[____]', 
        status: true, 
        cookie: true, 
        xfbml: true 
       }); 
       FB.XFBML.parse(); **- 1** 
     }; 
     FB.XFBML.parse(); **- 2** 
     (function() { 
      var e = document.createElement('script'); 
      e.type = 'text/javascript'; 
      e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js#xfbml=1'; 
      e.async = true; 
      document.getElementById('fb-root').appendChild(e); 
     }()); 
    </script> 

    Like button goes here:<fb:like></fb:like> 

    ... 

</body> 

</html> 

的问题是很简单,虽然脚本执行负载,从来没有出现按钮。我也通过Facebook Linter运行它,它不会突出任何问题。

任何想法?

那么这是令人尴尬的。我最终意识到,我的一个Firefox插件Ghostery阻止了Like按钮。

所以我最初发布的代码确实有效。

+0

有趣的是,你刚刚解决了我自己的挖掘时间。 –

在FB对象初始化后需要致电FB.XHTML.parse();

+0

我刚刚试过这个 - 我编辑了我原来的帖子来显示** - 1 **和** - 2 **,这两个位置我尝试了您的建议。 在这两个地方都没有区别。 我在原始文章中的代码(简单地排除了FB.XFBML.parse())与我在注册我的应用程序后的示例页面上提供的Facebook完全相同。 – awj

您是否尝试过使用同步引用来查看它是否有效?

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1" type="text/javascript"></script> 
<div id="fb-root"></div> 
+0

这没有什么区别。 – awj