Search code examples
javascripthtmlfacebookiframefacebook-comments

Facebook comments plugin loads an iframe in an iframe which causes non responsive width


I have loaded following code.

<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 = "https://connect.facebook.net/en_US/all.js#xfbml=1&appId=584188471733742&version=v2.5";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div style="width: 500px;">
    <div class="fb-comments" data-width="100%" data-numposts="15" data-colorscheme="light" data-mobile="false"
         data-order-by="reverse_time"></div>
</div>

As you see I define a 100% width. But the code that gets rendered is an iframe in an iframe with the first iframe that is correct and second with a fixed width of 600px.

I don't think there should be 2 iframes. See the provided image for the result. Any suggestions how to fix this

generated html code


Solution

  • Looks like facebook does not yet support the option to leave out the data-href attritbute when using the fluid width.

    see: https://developers.facebook.com/bugs/1543583425960050