问题
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