How to resize Facebook Canvas app (iFrame) correctly?

前端 未结 10 584
走了就别回头了
走了就别回头了 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:50

    We ran into an issue where their FB.Canvas functions didn't work, although everything was properly initialized, because they’re using ‘IFRAME’ instead of iframe in their cross-domain JS setup, hence no XHTML compatibility.

    We fixed this by prototyping our own createElement function and overriding theirs. Just put this right after you include Facebooks all.js:

    document.__createElement = document.createElement;
    document.createElement = function(tagName) {
                return document.__createElement(tagName.toLowerCase());
    }
    

提交回复
热议问题