2011-07-24 120 views
0

我想添加一個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運行它,它不會突出任何問題。

任何想法?

回答

7

那麼這是令人尷尬的。我最終意識到,我的一個Firefox插件Ghostery阻止了Like按鈕。

所以我最初發布的代碼確實有效。

+0

有趣的是,你剛剛解決了我自己的挖掘時間。 –

0

在FB對象初始化後需要致電FB.XHTML.parse();

+0

我剛剛試過這個 - 我編輯了我原來的帖子來顯示** - 1 **和** - 2 **,這兩個位置我嘗試了您的建議。 在這兩個地方都沒有區別。 我在原始文章中的代碼(簡單地排除了FB.XFBML.parse())與我在註冊我的應用程序後的示例頁面上提供的Facebook完全相同。 – awj

0

您是否嘗試過使用同步引用來查看它是否有效?

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

這沒有什麼區別。 – awj