【问题标题】:Facebook Share Button Doesn't WorkFacebook 分享按钮不起作用
【发布时间】:2016-06-06 00:09:26
【问题描述】:

我从 facebook 开发者那里得到这个代码:https://developers.facebook.com/docs/plugins/share-button

<html>
<head>
    <title>Your Website Title</title>
    <!-- You can use Open Graph tags to customize link previews.
    Learn more: https://developers.facebook.com/docs/sharing/webmasters -->
    <meta property="og:url"           content="http://www.your-domain.com/your-page.html" />
    <meta property="og:type"          content="website" />
    <meta property="og:title"         content="Your Website Title" />
    <meta property="og:description"   content="Your description" />
    <meta property="og:image"         content="http://www.your-domain.com/path/image.jpg" />
</head>
<body>

    <!-- Load Facebook SDK for JavaScript -->
    <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/sdk.js#xfbml=1";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

    <!-- Your share button code -->
    <div class="fb-share-button" 
        data-href="http://www.your-domain.com/your-page.html" 
        data-layout="button_count">
    </div>

</body>
</html>

什么都没有发生,没有按钮出现...怎么了?

Live Code on Code Pen

【问题讨论】:

    标签: jquery html css facebook facebook-javascript-sdk


    【解决方案1】:

    似乎没有添加实际的按钮元素。这就是所有的代码吗?就像是 ''button type="button">在 Facebook 上分享

    【讨论】:

      【解决方案2】:

      好的,一切似乎都在那里,您只需要添加一个实际的按钮。你有一个的代码和链接,但没有元素本身。 how to add a button via W3C

      【讨论】:

        【解决方案3】:

        您遗漏了这部分:“第 3 步:将此代码放置在您希望插件出现在页面上的任何位置”:

        <div class="fb-share-button" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button_count" data-mobile-iframe="false"></div>
        

        data-href 值需要是您自己的链接。

        【讨论】:

          【解决方案4】:

          问题是 ADBLOCK,它隐藏了 div...

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多