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

Web › JavaScript SDK › FB.Canvas.getPageInfo

Returns a Javascript object containing information about your app's canvas page. You need to provide a callback with the API, where we fetch the new value and return it.

As a Canvas app runs within an iframe it does not have access to window.innerHeight and window.innerWidth. This method exists to provide access to the client (browser) dimensions as well as the current scroll position and offset coordinates.

Examples

FB.Canvas.getPageInfo(
    function(info) {
        alert('Width: ' + info.clientWidth + ' Height: ' + info.clientHeight);
    }
);

Return

NameDescription
clientHeightInteger

The height of the viewport in pixels

clientWidthInteger

The width of the viewport in pixels

offsetLeftInteger

The number of pixels between the left edge of the viewport and the left edge of your app's iframe

offsetTopInteger

The number of pixels between the top edge of the viewport and the top edge of your app's iframe

scrollLeftInteger

The number of pixels between the left edge of your iframe and the left edge of your iframe's viewport

scrollTopInteger

The number of pixels between the top edge of your iframe and the top edge of your iframe's viewport

Parameters

NameTypeRequiredDescription
callbackFunctionno

Function called back with the app canvas info.

Updated about a month ago
Facebook © 2013 · English (US)
AboutAdvertisingCareersPlatform PoliciesPrivacy Policy