Skip to content

Instantly share code, notes, and snippets.

@stankusl
Created May 27, 2015 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stankusl/a388b9326d8ea0b4e573 to your computer and use it in GitHub Desktop.
Save stankusl/a388b9326d8ea0b4e573 to your computer and use it in GitHub Desktop.
Facebook page app force height.

provide these lines when calling initialization:

FB.Canvas.setSize({ height: (newHeight+20) }); setTimeout(function() { FB.Canvas.setSize({ height: (newHeight+40) }); }, 100);

Full code:

window.fbAsyncInit = function() {
    FB.init({
        appId      : 'thisIsYourAppID',
        xfbml      : true,
        version    : 'v2.3'
    });

    var wrapper = $("#wrapper");
    wrapper.height('auto');
    var newHeight = wrapper.height();
    wrapper.height(newHeight);
    FB.Canvas.setSize({ height: (newHeight+20) });

    setTimeout(function() {
        FB.Canvas.setSize({ height: (newHeight+40) });
    }, 100);

};

(function(d, s, id){
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
#wrapper {
width: 100%;
height: 100%;
overflow: hidden;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment