How to resize Facebook Canvas app (iFrame) correctly?

前端 未结 10 601
走了就别回头了
走了就别回头了 2021-02-06 09:25

I need to adjust canvas size after updating content of a page. I can do it explicitly by

FB.Canvas.setSize({ width: 760, height: 1480 });

howev

10条回答
  •  花落未央
    2021-02-06 09:58

    When resizing to the minimum height do not forget to make it a little bit bigger than it is, to account for horizontal scrolling bar and some extra pixels that some browsers add, otherwise you will end-up with vertical scroll.

    Also I do not recommend to use body to count height.

    This worked for me :

    window.fbAsyncInit = function() 
    {FB.Canvas.setSize({height:document.getElementById('m_table').offsetHeight+40});}
    

    where m_table is table ID with all my content (you can use div instead).

提交回复
热议问题