Facebook Canvas APP(Iframed)自动调整大小 [英] Facebook Canvas APP (Iframed) Auto-Height Resize

查看:136
本文介绍了Facebook Canvas APP(Iframed)自动调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近一直遇到Facebook canvas iframe应用程序的问题。我将设置设置为自动调整大小,并实现了正确的FB JS调用以调整高度(避免不必要的滚动条),但似乎不起作用。



有没有人有这个问题或想出一个解决方案?



谢谢!



Erik

解决方案

< / body> 我写了以下代码。

 < div id =fb-root>< ; / DIV> 
< script type =text / javascript>
window.fbAsyncInit = function(){
FB.init({
appId:'<??php echo YOU​​R_APP_ID?>',
cookie:true,
xfbml:true,
oauth:true
});
FB.Canvas.setAutoGrow(true);
};
(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);
}());
< / script>

这对我来说很正常。



在高级应用程序设置中 height Fixed或Fluid 无关紧要。



FB.Canvas.setAutoGrow(true); 在我的应用程序中不工作,但是我发现我错过了< div id =fb-root>< / div> 代码。我只是把它放在< script type =text / javascript> 之前,解决了问题。


Been running into an issue lately with Facebook canvas iframe applications. I've set our settings to "auto-resize" and implemented the correct FB JS call to do the resizing of the height (to avoid unwanted scrollbars), but it doesn't seem to be working.

Has anyone else had this issue or come up with a solution?

Thanks!

Erik

解决方案

Before </body> tag, I have written following code.

<div id="fb-root"></div>
<script type="text/javascript">
            window.fbAsyncInit = function() {
                FB.init({
                    appId: '<?php echo YOUR_APP_ID ?>',
                    cookie: true,
                    xfbml: true,
                    oauth: true
                });
                FB.Canvas.setAutoGrow(true);
            };
            (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);
            }());
</script>

And it is working fine for me.

It doesn't matter whether height is Fixed or Fluid in Advanced application settings.

FB.Canvas.setAutoGrow(true); was not working in my application, but I found that I missed the <div id="fb-root"></div> code. I just put it before <script type="text/javascript"> and got the issue resolved.

这篇关于Facebook Canvas APP(Iframed)自动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆