Automatic Canvas Resizing

This method is only enabled when Canvas Height is set to "Fixed at (800)px" in the App Dashboard.

The method FB.Canvas.setAutoGrow() starts or stops a timer which will grow your iframe to fit the content every few milliseconds. Default timeout is 100ms.

This method was previously called FB.Canvas.setAutoResize.

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

Examples

This function is useful if you know your content will change size, but you don't know when. There will be a slight delay, so if you know when your content changes size, you should call setSize() yourself (and save your user's CPU cycles).

window.fbAsyncInit = function() {
  FB.init({
    appId: 'YOUR_APP_ID', // App ID
  });
  FB.Canvas.setAutoGrow();
}

If you ever need to stop the timer, just pass false.

FB.Canvas.setAutoGrow(false);

If you want the timer to run at a different interval, you can do that too.

FB.Canvas.setAutoGrow(91); // Paul's favourite number

If there is only 1 parameter and it is a number, it is assumed to be the interval.

Parameters

NameTypeRequiredDescription

onOrOff

boolean

yes

Whether to turn the timer on or off. truthy == on, falsy == off. default is true

interval

integer

yes

How often to resize (in ms). default is 100ms