Facebook赞按钮无法显示

时间:2011-07-24 08:48:14

标签: facebook-like

我正在尝试将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>

问题很简单,当脚本加载时, Like 按钮永远不会出现。我也通过Facebook Linter运行它,但没有强调任何问题。

有什么想法吗?

3 个答案:

答案 0 :(得分:7)

这很令人尴尬。我终于意识到我的一个Firefox附加组件Ghostery阻止了Like按钮。

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

答案 1 :(得分:0)

初始化FB对象后,需要调用FB.XHTML.parse();

答案 2 :(得分:0)

您是否尝试过同步参考以查看它是否有效?

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