Manual Canvas Resizing

This method is only enabled when Canvas Height is set to "Fluid" in the App Dashboard

The method FB.Canvas.setSize() tells Facebook to resize your Canvas iframe. If you do not specific any parameters Facebook will attempt to determine the height of the Canvas app and set the iframe accordingly. If you would like to set the dimension explicitly pass in an object with height and width properties.

If the Canvas Width toggle in set to "Fixed (760px)" in the App Dashboard the max width is 760 pixels. There is no max height.

NOTE: When using this method, ensure that window.name is not overridden as that can cause issues.

Examples

Call this whenever you need a resize. This usually means, once after pageload, and whenever your content size changes. The example below will attempt to determine the size of the Canvas app content and set the height automatically.

FB.Canvas.setSize();

When determining the Canvas Height automatically the height it can only be increased, not decreased. When possible please pass the explicit dimensions as properties of an object.

FB.Canvas.setSize({ width: 640, height: 480 });

Parameters

This call has a single required object with the name params. The object must have the following properties set on it:

PropertyTypeDescriptionArgumentDefault

width

integer

Desired width. Max is app width.

Optional

frame width

height

integer

Desired height.

Optional

frame height