Iframe Auto-Resize

621 Views Asked by At

Dear FB Developer Team,

we have an issue with the FB.Canvas.setAutoResize() function of the app iframe. The frame extends vertically to the height of the first request, but on subsequent requests to pages with a lower height, the iframe doesn't resize vertically.

While we tried the FB.Canvas.setAutoResize() function, it seems not to work.

Could we somehow solve this issue?

Would be great to receive an answer here.

Best, Max

1

There are 1 best solutions below

0
On

This is a known Facebook issue, they're renaming setAutoResize to setAutoGrow for exactly this reason.

When your page shrinks in size you should use FB.Canvas.setSize to lower the height https://developers.facebook.com/docs/reference/javascript/FB.Canvas.setSize/

There have been several bugs reported about how FB.Canvas.setAutoResize doesn’t set the height of the iframe correctly in some scenarios. We have been trying to fix this and and have pushed various fixes to ensure that it works correctly for the case when the iframe grows in height. We however came to the conclusion that it is hard for us to do this accurately when the iframe shrinks in height. As a result we are renaming this function to FB.Canvas.setAutoGrow so that it accurately reflects its functionality. If your iframe is shrinking for whatever reason we recommend that you use FB.Canvas.setSize with a height parameter to set the iframe height explicitly.

As part of this change, you should be able to use FB.Canvas.setAutoGrow today. FB.Canvas.setAutoResize will work for the next 90 days and we will remove support for this method on January 1st, 2012. Here is some sample code to test the grow functionality.

https://developers.facebook.com/blog/post/565/