0

这是我的html页面代码

    <html>

    <head>
        <title>Big Query & D3.js Mashup</title>
        <meta property="og:title" content="My Site"/>
        <meta property="og:type" content="website" />
        <meta property="og:url" content="http:xample.com" />
        <meta property="og:image" content="" />
        <meta property="og:site_name" content="Data" />
        <meta property="fb:admins" content="1" />
    </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.net/en_US/all.js#xfbml=1";
                fjs.parentNode.insertBefore(js, fjs);
            }(document, 'script', 'facebook-jssdk'));
        </script>   <a href="https://twitter.com/share" class="twitter-share-button"
        data-url="http:xample.com" data-via="jmy" data-lang="en">Tweet</a>

        <script>
            ! function (d, s, id) {
                var js, fjs = d.getElementsByTagName(s)[0];
                if (!d.getElementById(id)) {
                    js = d.createElement(s);
                    js.id = id;
                    js.src = "https://platform.twitter.com/widgets.js";
                    fjs.parentNode.insertBefore(js, fjs);
                }
            }(document, "script", "twitter-wjs");
        </script>
        <div class="fb-like" data-href="http:xample.com/" data-send="false"
        data-layout="button_count" data-width="450" data-show-faces="true" data-font="arial"></div>
    </body>

</html>

更新代码:

    <html>

<head>
    <title>Big Query & D3.js Mashup</title>
    <meta property="og:title" content="My Site"/>
    <meta property="og:type" content="website" />
    <meta property="og:url" content="http:xample.com" />
    <meta property="og:image" content="" />
    <meta property="og:site_name" content="Data" />
    <meta property="fb:admins" content="1" />
</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.net/en_US/all.js#xfbml=1";
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));
    </script>   <a href="https://twitter.com/share" class="twitter-share-button"
    data-url="http://xample.com" data-via="jmy" data-lang="en">Tweet</a>

    <script>
        ! function (d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (!d.getElementById(id)) {
                js = d.createElement(s);
                js.id = id;
                js.src = "https://platform.twitter.com/widgets.js";
                fjs.parentNode.insertBefore(js, fjs);
            }
        }(document, "script", "twitter-wjs");
    </script>
    <div class="fb-like" data-href="http://xample.com/" data-send="false"
    data-layout="button_count" data-width="450" data-show-faces="true" data-font="arial"></div>
</body>
</html>

Twitter 链接出现,但 facebook 链接没有出现。

4

1 回答 1

2

url 错误应该是http://www.example.com而不是 http:xample.com

 <div class="fb-like" data-href="http://www.example.com/" data-send="false"
    data-layout="button_count" data-width="450" data-show-faces="true" data-font="arial">

http://jsfiddle.net/E6xYU/2/

于 2012-11-27T16:01:21.980 回答