调整应用程序的画布大小
我们一直在努力为canvas应用程序设置高度,而不用运气。
we have been trying to setup the height for a canvas app without luck.
这是我们使用的代码
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);
}
我们尝试过没有sizechangecallback
We tried both without the sizechangecallback
,我们的设置设置为固定和固定950
and our settings set to Fixed and Fixed 950
在应用程序设置中设置固定高度参数后,
您可以调用 FB.Canvas.setSize
来更改页面高度。
After you setup the fixed height parameter in your application settings,
you can call FB.Canvas.setSize
to change the page height.
如果您的页面高度动态变化,则可以运行 FB.Canvas.setDoneLoading
来检查Canvas是否已加载并运行 FB .Canvas.setAutoGrow
。
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文档: https://developers.facebook.com/docs/reference/javascript/FB.Canvas.setDoneLoading/