Javascript facebook选项卡不再调整大小

Javascript facebook选项卡不再调整大小,javascript,facebook,facebook-graph-api,tabs,facebook-javascript-sdk,Javascript,Facebook,Facebook Graph Api,Tabs,Facebook Javascript Sdk,有人知道调整facebook标签iframe大小的代码最近是否发生了变化吗 我过去常在头上加上这样一句话: <script type="text/javascript"> window.fbAsyncInit = function() { FB.Canvas.setSize( {height: 1040} ); } // Do things that will sometimes call sizeChangeCallback() function sizeChangeC

有人知道调整facebook标签iframe大小的代码最近是否发生了变化吗

我过去常在头上加上这样一句话:

<script type="text/javascript">
window.fbAsyncInit = function() 
{ 
   FB.Canvas.setSize( {height: 1040} );
}

// Do things that will sometimes call sizeChangeCallback()
function sizeChangeCallback() 
{
    FB.Canvas.setSize( {height: 1040} );
}
</script>

window.fbAsyninit=函数()
{ 
FB.Canvas.setSize({height:1040});
}
//做一些有时会调用sizeChangeCallback()的事情
函数sizeChangeCallback()
{
FB.Canvas.setSize({height:1040});
}
在身体里:

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
   FB.init({
      appId : '561492603881225',
      status : true, // check login stat
      cookie : true, // enable cookies to allow the server to access the session
      xfbml : true // parse XFBML 
});
</script>

FB.init({
appId:'56149603881225',
状态:true,//检查登录状态
cookie:true,//启用cookie以允许服务器访问会话
xfbml:true//解析xfbml
});
所有需要更改的是应用程序ID和setSize脚本中的值,然后我可以设置高度以匹配每个选项卡上的内容


但是现在看看我的标签,所有的标签似乎都重置回了默认的800px高,这让我觉得facebook改变了他们做事的方式,但在任何地方都找不到任何东西,在开发者博客上也没有看到任何东西。

你首先必须检查画布是否已加载-

FB.Canvas.setDoneLoading( function(response) {
    console.log(response.time_delta_ms);
    FB.Canvas.setAutoGrow();
});


或者,您也可以在负重后进行尝试,这似乎可以在不设置高度的情况下工作,可能是一种响应性解决方案

<div id="fb-root"></div>
<script type="text/javascript">
fb_root = document.createElement( 'div' );
fb_root.id = 'fb-root';
try
{
window.document.childNodes[0].appendChild( fb_root );
}
catch( error )
{
window.document.body.appendChild( fb_root );
}

window.fbAsyncInit = function() {
FB.init({
appId  : '1375967019301812', //your app ID
status : true, // check login status
cookie : true // enable cookies to allow the server to access the session
});

//FB.Canvas.setSize({ width: 520, height: 1400 });

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

var mySetSize = function() {
    var height = getDocHeight();
    FB.Canvas.setSize({ width: 520, height: height });
    setTimeout( mySetSize, 200 );
};
setTimeout( mySetSize, 200 );
};

(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
  '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());


var head = document.getElementsByTagName('head')[0],
style = document.createElement('style'),
rules = document.createTextNode('body { position: relative; max-width:     520px!important;width: 520px!important; overflow: hidden!important; margin: 0px!important;     }');

style.type = 'text/css';
if(style.styleSheet)
style.styleSheet.cssText = rules.nodeValue;
else style.appendChild(rules);
head.appendChild(style);

</script>

fb_root=document.createElement('div');
fb_root.id='fb root';
尝试
{
window.document.childNodes[0].appendChild(fb\U根);
}
捕获(错误)
{
window.document.body.appendChild(fb_root);
}
window.fbAsyninit=函数(){
FB.init({
appId:'1375967019301812',//您的应用ID
状态:true,//检查登录状态
cookie:true//启用cookie以允许服务器访问会话
});
//FB.Canvas.setSize({宽度:520,高度:1400});
函数getDocHeight(){
var D=文件;
返回Math.max(
max(D.body.scrollHeight,D.documentElement.scrollHeight),
max(D.body.offsetHeight,D.documentElement.offsetHeight),
max(D.body.clientHeight,D.documentElement.clientHeight)
);
}
var mySetSize=function(){
var height=getDocHeight();
FB.Canvas.setSize({width:520,height:height});
setTimeout(mySetSize,200);
};
setTimeout(mySetSize,200);
};
(功能(){
var e=document.createElement('script');e.async=true;
e、 src=document.location.protocol+
“//connect.facebook.net/en_US/all.js”;
document.getElementById('fb-root').appendChild(e);
}());
var head=document.getElementsByTagName('head')[0],
style=document.createElement('style'),
rules=document.createTextNode('正文{位置:相对;最大宽度:520px!重要;宽度:520px!重要;溢出:隐藏!重要;边距:0px!重要;}');
style.type='text/css';
if(style.styleSheet)
style.styleSheet.cssText=rules.nodeValue;
else样式。追加子项(规则);
头。附属物(样式);

我使用了下面的“FB.Canvas.setAutoGrow();”??我也读过,但它从未对我起作用,所以setsize对我来说总是可以的。刚刚尝试用setAutogrow替换它,但没有成功??这会在头中的另一个脚本之前进入脚本标记吗?在
FB.init()之后使用它