The Perfect Solution to Resize your Facebook App Canvas

Today, Facebook announces that they are renaming the setAutoResize in the JavaScript SDK to setAutoGrow.

It is true that from time to time, people are reporting that autoresize does not work for their canvas apps.  It is in fact good to see that Facebook admit that they cannot solve the all case, especially when the iframe shrinks in height.

We never expect all issues can be resolved but it would be good to set our expectation.  Renaming the function to FB.Canvas.setAutoGrow at least tell us what it can handle and reflects its functionality.

For me, when autoresize does not work for my canvas apps, what I do is to try cleaning up my HTML code (hoping that after the clean up, JavaScript SDK can calculate the height of my canvas area accurately).  And if it still fails, I will set the canvas size explicitly by using FB.Canvas.setSize (to set it to a reasonable size for displaying the page to the user) and then call setAutoResize (so that JavaScript SDK can be the auto-resize by growing the canvas area).

This is actually what Facebook has just announced.


This entry was posted in Development Tips, news and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *