Like button not showing (except jsfiddle)

佐手、 提交于 2019-12-11 16:26:16

问题


My problem is, that the like button is not showing, when I try to run it local. On JSfiddle it works, I don't understand why.

JSFiddle: http://jsfiddle.net/fmzu6738/

With the code I want to achieve, if I click the like button, I like the page and the page automatically redirect to the facebook side

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#">
<head>
    <title>bla</title>
</head>
<body>
    <div id="Div1">
    </div>
    <script type="text/javascript">
        (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>

        <div id="fb-root">
        </div>
        <fb:like href="https://www.facebook.com/Bxyz" send="true" show_faces="false" data-layout="button" data-action="like" data-show-faces="false" data-share="false">
        </fb:like>
        <script src="http://connect.facebook.net/en_US/all.js"></script>
        <script>
            FB.init({
                status: true, // check login status
                cookie: true, // enable cookies to allow the server to access the session
                xfbml: true  // parse XFBML
            });
        </script>
        <script type="text/javascript">

            FB.Event.subscribe('edge.create', window.location.href = "https://www.facebook.com/xyz";);

        </script>

</body>
</html>

What is wrong here? Thank you very much!


回答1:


Facebook api requires HTTP Server like "apache, IIS, etc.." make sure you'r working local-server like "xammp, apache, mamp for mac"



来源:https://stackoverflow.com/questions/25856560/like-button-not-showing-except-jsfiddle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!