问题
we have been trying to setup the height for a canvas app without luck.
this is the code we are using
window.fbAsyncInit = function()
{
// assume we are already logged in
FB.init({appId: '<?=$fb_app_id ?>', xfbml: true, oauth : true,cookie: true});
FB.Canvas.setAutoGrow();
}
function sizeChangeCallback() {
FB.Canvas.setSize({ width: 810, height: 950);
}
We tried both without the sizechangecallback
and our settings set to Fixed and Fixed 950
回答1:
After you setup the fixed height parameter in your application settings,
you can call FB.Canvas.setSize
to change the page height.
If your page height changes dynamically, you can run FB.Canvas.setDoneLoading
to check if Canvas is loaded and run FB.Canvas.setAutoGrow
.
window.fbAsyncInit = function() {
// assume we are already logged in
FB.init({ appId: '<?=$fb_app_id ?>', xfbml: true, oauth: true, cookie: true });
FB.Canvas.setSize({ width: 810, height: 950 });
FB.Canvas.setDoneLoading( function(response) {
console.log(response.time_delta_ms);
FB.Canvas.setAutoGrow();
});
}
FB Documentation: https://developers.facebook.com/docs/reference/javascript/FB.Canvas.setDoneLoading/
来源:https://stackoverflow.com/questions/11270906/resizing-canvas-for-the-app