Facebook Developers
DocsToolsSupportNewsApps
Log In
  • Social Plugins
  • Facebook Login
  • Open Graph
  • Facebook APIs
  • Games
  • Media
  • Payments
  • App Center
  • Promote Your App
  • iOS
  • Android
  • Web
    • Getting Started
    • JavaScript SDK
    • PHP SDK
    • More SDKs
    • Facebook for WordPress
  • Technology Partners
  • Core Methods
    • FB.api
    • FB.init
    • FB.ui
  • Auth Methods
    • FB.getAuthResponse
    • FB.getLoginStatus
    • FB.login
    • FB.logout
  • Event Handling
    • FB.Event.subscribe
    • FB.Event.unsubscribe
  • XFBML
    • FB.XFBML.parse
  • Canvas Methods
    • FB.Canvas.Prefetcher.addStaticResource
    • FB.Canvas.Prefetcher.setCollectionMode
    • 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.setSize

Web › JavaScript SDK › FB.Canvas.setSize

Note: this method is only enabled when Canvas Height is set to "Fluid" in the App Dashboard.

Tells Facebook to resize your 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.

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();

Note: 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

NameTypeRequiredDescription
paramsObjectyes
Property Type Description Argument Default
width Integer Desired width. Max is app width. Optional frame width
height Integer Desired height. Optional frame height
Updated about 7 months ago
Facebook © 2013 · English (US)
AboutAdvertisingCareersPlatform PoliciesPrivacy Policy