Facebook Like buttons not displaying when loaded hidden

前端 未结 10 2115
梦毁少年i
梦毁少年i 2020-12-15 04:18

I\'m a bit stuck with this one. I have an article list with snippets that link off to the full article. when you hover over each blurb a bar appears at the bottom of the blu

10条回答
  •  伪装坚强ぢ
    2020-12-15 04:46

    An alternative that I used was to not render the fb like button until the container is displayed this can be acheived by using

    window.fbAsyncInit = function () {
        FB.init({
            xfbml:false  // Will stop the fb like button from rendering automatically
        });
    };
    

    Then to render the like button you can use

    FB.XFBML.parse(); // This will render all tags on the page
    

    or the following is a Jquery example on how to render all XFBML within an element

    FB.XFBML.parse($('#step2')[0]); 
    

    or plain javascript

    FB.XFBML.parse(document.getElementById("step2"));
    

提交回复
热议问题