Facebook Developers
DocumentationSupportBlogAppsLog In
  • Getting Started
  • Core Concepts
  • Advanced Topics
  • SDK Reference
    • JavaScript SDK
    • PHP SDK
    • iOS SDK
    • Android SDK
  • Tools
  • Core Methods
    • FB.api
    • FB.init
    • FB.ui
  • Auth Methods
    • FB.getAuthResponse
    • FB.getLoginStatus
    • FB.getSession
    • FB.login
    • FB.logout
  • Event Handling
    • FB.Event.subscribe
    • FB.Event.unsubscribe
  • XFBML Methods
    • FB.XFBML.parse
  • Canvas Methods
    • FB.Canvas.Prefetcher.addStaticResource
    • FB.Canvas.Prefetcher.setCollectionMode
    • FB.Canvas.getPageInfo
    • FB.Canvas.hideFlashElement
    • FB.Canvas.scrollTo
    • FB.Canvas.setAutoGrow
    • FB.Canvas.setDoneLoading
    • FB.Canvas.setSize
    • FB.Canvas.setUrlHandler
    • FB.Canvas.showFlashElement
    • FB.Canvas.startTimer
    • FB.Canvas.stopTimer

FB.Canvas.setAutoGrow

SDK Reference › JavaScript SDK › FB.Canvas.setAutoGrow

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

Starts or stops a timer which will grow your iframe to fit the content every few milliseconds. Default timeout is 100ms.

Used to be known as FB.Canvas.setAutoResize.

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
    channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
  });
  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

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

Parameters

NameTypeDescription
onOrOffBoolean

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

intervalInteger

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

Updated about 2 weeks ago
Facebook © 2012 · English (US)
AboutCareersPlatform PoliciesPrivacy Policy