Skip to content

Instantly share code, notes, and snippets.

@jimmyhillis
Created February 19, 2013 01:46
Show Gist options
  • Save jimmyhillis/4982408 to your computer and use it in GitHub Desktop.
Save jimmyhillis/4982408 to your computer and use it in GitHub Desktop.
Remove the default height restriction from Facebook iFrame tabs with a simple JavaScript callback run as soon as the Facebook SDK is initialized.
window.fbAsyncInit = function() {
FB.init({
appId: '415273505232476',
status: true,
cookie: true,
xfbml: true
});
FB.Canvas.setAutoGrow();
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
@jimmyhillis
Copy link
Author

This can be placed in an included JS file within your app code or "inline" within the <head> tags if you aren't using any other code and want to keep requests down. Don't wrap any of this code within a $(document).ready() callback if you are using jQuery; it should be global.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment