FB.Canvas.setSize({ width: 760,height: 1480 });
但是,没有参数,它就不起作用,即.setSize().
另外,我可以调整高度
FB.Canvas.setAutoResize(true);
以下行不起作用:
FB.Arbiter.inform("setSize",FB.Canvas._computeContentSize()); FB.Canvas.setSize(FB.Canvas._computeContentSize());
怎么能让它发挥作用?
关于这个问题的更多评论:
> http://developers.facebook.com/blog/post/93
> http://developers.facebook.com/docs/reference/javascript/fb.canvas.setautoresize
有关:
> facebook-api: what’s Facebook Connect cross-domain receiver URL?
> facebook-app: how can i change the height of a resizeable iframe application?
> Document height grows on resize when setting canvas dimensions dynamically
你如何控制Facebook Canvas应用程序的大小?
解决方法
FB.Canvas.setAutoResize();
如果您知道何时需要调整大小,请使用
FB.Canvas.setSize()
因此,如果您想在单击链接时使其更小,请将其粘贴到函数中,然后再调用该函数,如:
function sizeChangeCallback() { FB.Canvas.setSize(); } //start some function or on click event - here i used jquery $("#something").click(function() { sizeChangeCallback() });
您不需要设置显式高度,但有时您可能会遇到像注释插件这样的动态xfbml元素的问题.尝试使用事件订阅回调:
FB.Event.subscribe('xfbml.render',function(response) { FB.Canvas.setAutoResize(); });
http://developers.facebook.com/docs/reference/javascript/FB.Canvas.setSize/
http://developers.facebook.com/docs/reference/javascript/FB.Canvas.setAutoResize/
http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/