我创建了一个Facebook应用程序,它将作为选项卡显示在我的公司粉丝页面上.该应用程序渲染为951px,因此它不适合粉丝页面选项卡的默认高度.我已经阅读了facebook的js sdk的可怕文档,并尝试了很多不同的变化 - 所有这些都没有工作.这是我目前尝试调整粉丝页面选项卡的大小以适合我的应用程序...
<head>
<!-- css / js / meta info here -->
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.Canvas.setSize();
}
function sizeChangeCallback() {
FB.Canvas.setSize();
}
</script>
</head>
<body>
<!-- content goes here -->
<div id="fb-root">
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
FB.init({
appId:'xxxxxxxxxx',
status:true,
cookie:true,
xfbml:true,
});
</script>
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
我也尝试过async init并使用setAutoResize()没有运气.
感谢您提出的所有建议...... B.
Waq*_*gir 16
<head>
<script type="text/javascript">
window.fbAsyncInit = function()
{
FB.Canvas.setSize();
}
</script>
</head>
.
.
.
.
<div id="fb-root"></div>
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
FB.init({
appId: 'xxxxxxxx',
status: true,
cookie: true,
xfbml: true
});
/* Init fb Resize window */
/* Completly removed now in JS SDK*/
/* FB.Canvas.setAutoResize(7); */
/* As of Jan 2012 you need to use */
FB.Canvas.setAutoGrow(7);
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我花了一个多小时试图在我的应用程序中解决这个问题,我想提一下你必须遵循的几个基础知识才能实现.
我的代码中没有错误,但它拒绝工作,因为我在<head>元素中包含all.js和我的JS代码,而我的fb-root div在<body>中.以下是我必须将其更改为:
...
<head>
<!-- include jQuery so we can use window.load below -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" ></script>
...
</head>
<body>
<!-- the div has to come first which forces the JS include and code to be put below it -->
<div id="fb-root"></div>
<!-- then we have to include the all.js file -->
<script src="https://connect.facebook.net/en_US/all.js" type="text/javascript"></script>
<!-- and finally we can use the FB JS SDK and it will actually work :) -->
<script type="text/javascript" charset="utf-8">
FB.init({
appId: '...',
status: true,
cookie: true,
xfbml: true
});
jQuery(window).load(function(){
//resize our tab app canvas after our content has finished loading
FB.Canvas.setSize();
});
</script>
...
Run Code Online (Sandbox Code Playgroud)
显然,我提到的3个元素并不一定要在彼此之后,但它们必须在源代码中按此顺序显示.这真的把我扔了一个循环所以希望这会节省一些时间和挫折:)
| 归档时间: |
|
| 查看次数: |
21587 次 |
| 最近记录: |