Facebook App - Javascript Set Height of Canvas?

安稳与你 提交于 2019-12-13 07:11:13

问题


I am trying to set the height so I don't have a scrollbar in my facebook app, seen HERE

I have used jQuery to create the canvas plugin using the GRAPH API and have tried adding the following codes to edit the height but none work. Anyone have any ideas?

In my scripts.js I try adding the following to the bottom:

FB.Canvas.setAutoResize();  //doesn't work

Also tried the following:

window.fbAsyncInit = function() {
FB.Canvas.setSize({ height: 2500 });
}; //doesn't work either

回答1:


window.fbAsyncInit = function() {
   FB.Canvas.setSize({height: 1050});
}

// Do things that will sometimes call sizeChangeCallback()
function sizeChangeCallback() {
   FB.Canvas.setSize();
}



回答2:


Just for clarification for other users who happen on this content:

  • Add the

    <script src="http://connect.facebook.net/en_US/all.js"></script> and <script> FB.init({ appId : 'here_your_API_id', status : true, cookie : true, xfbml : true }); </script>

    code before your </head> tag.

  • Add the <div id="fb-root"></div>

<script src="http://connect.facebook.net/en_US/all.js"></script>

`<script>window.fbAsyncInit = function() {FB.Canvas.setSize({height: 1050});}`
`function sizeChangeCallback() {FB.Canvas.setSize();}</script>`

portion right before the </body> tag.

  • If all else fails, try the following:

    <style>body {width:500px; height:1050px;overflow:hidden;margin:0; padding:0; border:0;}</style>



来源:https://stackoverflow.com/questions/7031977/facebook-app-javascript-set-height-of-canvas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!