0

私はサンプルコードを持っています:Javascriptで:

function initFB(appId) {
    this.appId = appId;
    window.fbAsyncInit = function() {
        FB.init({appId: appId, status: true, cookie: true, xfbml: true});

        // Additional initialization code such as adding Event Listeners goes here
        insertLikeButton('https://www.facebook.com/cocacola', 'facebooklike')
    };

    if(document.getElementById('fb-root')) return;
    var fbr = document.createElement('div'); fbr.id = 'fb-root';
    document.getElementsByTagName('body')[0].appendChild(fbr);
    (function(d, s, id, appId) {
        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&appId=' + appId;
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk', this.appId));

    function insertLikeButton(url, id) {
        var lb = document.createElement('fb:like');
        lb.id = 'fblike';
        lb.setAttribute('width', '450');
        lb.setAttribute('href', this.url);
        lb.setAttribute('show_faces', 'false');

        lb.style.overflow = 'hidden';
        lb.style.cursor = 'pointer';
        lb.style.width = '50px';
        lb.style.height = '25px';
        lb.style.zIndex = '99999';
        document.getElementById(this.id).appendChild(lb);
    }  
}

そしてhtml

<div id="facebooklike"></div>
<script>
var fb = new initFB('zzzzzz');
</script>

ボタンが表示されないなどのコードを実行すると、どうすれば修正できますか?

4

0 に答える 0