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.setSize

SDK Reference › JavaScript SDK › FB.Canvas.setSize

Note: this method is only enabled when Canvas Height is set to "Settable (Default: 800px)" 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

NameTypeDescription
paramsObject
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 2 weeks ago
Facebook © 2012 · English (US)
AboutCareersPlatform PoliciesPrivacy Policy